Use assertIsInstance in tests.

Gives much nicer errors when it fails.
This commit is contained in:
Marc Tamlyn 2013-05-21 10:42:15 +01:00
parent 18856f866c
commit 09f8652765
31 changed files with 87 additions and 87 deletions

View file

@ -74,7 +74,7 @@ class DataTypesTestCase(TestCase):
database should be unicode."""
d = Donut.objects.create(name='Jelly Donut', review='Outstanding')
newd = Donut.objects.get(id=d.id)
self.assertTrue(isinstance(newd.review, six.text_type))
self.assertIsInstance(newd.review, six.text_type)
@skipIfDBFeature('supports_timezones')
def test_error_on_timezone(self):
@ -90,7 +90,7 @@ class DataTypesTestCase(TestCase):
a Python datetime.date, not a datetime.datetime"""
b = RumBaba.objects.create()
# Verify we didn't break DateTimeField behavior
self.assertTrue(isinstance(b.baked_timestamp, datetime.datetime))
self.assertIsInstance(b.baked_timestamp, datetime.datetime)
# We need to test this this way because datetime.datetime inherits
# from datetime.date:
self.assertTrue(isinstance(b.baked_date, datetime.date) and not isinstance(b.baked_date, datetime.datetime))
self.assertIsInstance(b.baked_date, datetime.date) and not isinstance(b.baked_date, datetime.datetime)