From 64ed38332fed02e2c27323fa877dd26843da94df Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 11 Sep 2020 12:09:34 +0200 Subject: [PATCH] Refactoring and testing __str__ --- .../lostplaces_app/tests/models/test_place_model.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lostplaces/lostplaces_app/tests/models/test_place_model.py b/lostplaces/lostplaces_app/tests/models/test_place_model.py index 3996bd6..2ca5ef5 100644 --- a/lostplaces/lostplaces_app/tests/models/test_place_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_place_model.py @@ -4,9 +4,8 @@ from django.test import TestCase from django.db import models from lostplaces_app.models import Place -from lostplaces_app.tests.models import TestSubmittable +from lostplaces_app.tests.models import SubmittableTestCase from lostplaces_app.tests import mock_user -from lostplaces_app.tests.models import TestModel from taggit.managers import TaggableManager @@ -24,7 +23,7 @@ def mock_place(): return place -class PlaceTestCase(TestSubmittable, TestCase): +class PlaceTestCase(SubmittableTestCase, TestCase): model_name = 'Place' related_name = 'places' nullable = True @@ -127,10 +126,9 @@ class PlaceTestCase(TestSubmittable, TestCase): ) def test_str(self): - place = mock_place() - self.assertEqual(str(place), place.name, - msg='%s __str__ should return the name' % ( + place = self.object + self.assertTrue(place.name.lower() in str(place).lower(), + msg='Expecting %s.__str__ to contain the name' % ( self.model_name ) - )