Used assertIsInstance in tests.
This commit is contained in:
parent
40768ec29d
commit
d91321e8be
|
@ -93,4 +93,5 @@ class DataTypesTestCase(TestCase):
|
|||
self.assertIsInstance(b.baked_timestamp, datetime.datetime)
|
||||
# We need to test this way because datetime.datetime inherits
|
||||
# from datetime.date:
|
||||
self.assertIsInstance(b.baked_date, datetime.date) and not isinstance(b.baked_date, datetime.datetime)
|
||||
self.assertIsInstance(b.baked_date, datetime.date)
|
||||
self.assertNotIsInstance(b.baked_date, datetime.datetime)
|
||||
|
|
|
@ -256,8 +256,8 @@ class DeferRegressionTest(TestCase):
|
|||
deferred_item1 = deferred_class_factory(Item, ('name',))
|
||||
deferred_item2 = deferred_class_factory(deferred_item1, ('value',))
|
||||
self.assertIs(deferred_item2._meta.proxy_for_model, Item)
|
||||
self.assertFalse(isinstance(deferred_item2.__dict__.get('name'), DeferredAttribute))
|
||||
self.assertTrue(isinstance(deferred_item2.__dict__.get('value'), DeferredAttribute))
|
||||
self.assertNotIsInstance(deferred_item2.__dict__.get('name'), DeferredAttribute)
|
||||
self.assertIsInstance(deferred_item2.__dict__.get('value'), DeferredAttribute)
|
||||
|
||||
def test_deferred_class_factory_no_attrs(self):
|
||||
deferred_cls = deferred_class_factory(Item, ())
|
||||
|
|
|
@ -135,7 +135,7 @@ class DispatcherTests(unittest.TestCase):
|
|||
self.assertIsInstance(err, ValueError)
|
||||
self.assertEqual(err.args, ('this',))
|
||||
self.assertTrue(hasattr(err, '__traceback__'))
|
||||
self.assertTrue(isinstance(err.__traceback__, TracebackType))
|
||||
self.assertIsInstance(err.__traceback__, TracebackType)
|
||||
a_signal.disconnect(fails)
|
||||
self.assertTestIsClean(a_signal)
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ class FieldsTests(SimpleTestCase):
|
|||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
|
||||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
|
||||
self.assertEqual(1, f.clean('1'))
|
||||
self.assertEqual(True, isinstance(f.clean('1'), int))
|
||||
self.assertIsInstance(f.clean('1'), int)
|
||||
self.assertEqual(23, f.clean('23'))
|
||||
self.assertRaisesMessage(ValidationError, "'Enter a whole number.'", f.clean, 'a')
|
||||
self.assertEqual(42, f.clean(42))
|
||||
|
@ -191,7 +191,7 @@ class FieldsTests(SimpleTestCase):
|
|||
self.assertEqual(None, f.clean(None))
|
||||
self.assertEqual('None', repr(f.clean(None)))
|
||||
self.assertEqual(1, f.clean('1'))
|
||||
self.assertEqual(True, isinstance(f.clean('1'), int))
|
||||
self.assertIsInstance(f.clean('1'), int)
|
||||
self.assertEqual(23, f.clean('23'))
|
||||
self.assertRaisesMessage(ValidationError, "'Enter a whole number.'", f.clean, 'a')
|
||||
self.assertEqual(1, f.clean('1 '))
|
||||
|
@ -283,7 +283,7 @@ class FieldsTests(SimpleTestCase):
|
|||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
|
||||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
|
||||
self.assertEqual(1.0, f.clean('1'))
|
||||
self.assertEqual(True, isinstance(f.clean('1'), float))
|
||||
self.assertIsInstance(f.clean('1'), float)
|
||||
self.assertEqual(23.0, f.clean('23'))
|
||||
self.assertEqual(3.1400000000000001, f.clean('3.14'))
|
||||
self.assertEqual(3.1400000000000001, f.clean(3.14))
|
||||
|
@ -347,7 +347,7 @@ class FieldsTests(SimpleTestCase):
|
|||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
|
||||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
|
||||
self.assertEqual(f.clean('1'), Decimal("1"))
|
||||
self.assertEqual(True, isinstance(f.clean('1'), Decimal))
|
||||
self.assertIsInstance(f.clean('1'), Decimal)
|
||||
self.assertEqual(f.clean('23'), Decimal("23"))
|
||||
self.assertEqual(f.clean('3.14'), Decimal("3.14"))
|
||||
self.assertEqual(f.clean(3.14), Decimal("3.14"))
|
||||
|
@ -1389,7 +1389,7 @@ class FieldsTests(SimpleTestCase):
|
|||
def test_splitdatetimefield_1(self):
|
||||
from django.forms.widgets import SplitDateTimeWidget
|
||||
f = SplitDateTimeField()
|
||||
assert isinstance(f.widget, SplitDateTimeWidget)
|
||||
self.assertIsInstance(f.widget, SplitDateTimeWidget)
|
||||
self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean([datetime.date(2006, 1, 10), datetime.time(7, 30)]))
|
||||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None)
|
||||
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '')
|
||||
|
|
|
@ -775,7 +775,7 @@ class FormsTestCase(TestCase):
|
|||
self.assertFalse(form.is_valid())
|
||||
|
||||
# Check that update_error_dict didn't lose track of the ErrorDict type.
|
||||
self.assertTrue(isinstance(form._errors, forms.ErrorDict))
|
||||
self.assertIsInstance(form._errors, forms.ErrorDict)
|
||||
|
||||
self.assertEqual(dict(form.errors), {
|
||||
'code': ['Code error 1.', 'Code error 2.', 'Code error 3.'],
|
||||
|
|
|
@ -109,7 +109,7 @@ class DataSourceTest(unittest.TestCase):
|
|||
# http://trac.osgeo.org/gdal/ticket/3783
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(True, isinstance(layer.extent, Envelope))
|
||||
self.assertIsInstance(layer.extent, Envelope)
|
||||
self.assertAlmostEqual(source.extent[0], layer.extent.min_x, 5)
|
||||
self.assertAlmostEqual(source.extent[1], layer.extent.min_y, 5)
|
||||
self.assertAlmostEqual(source.extent[2], layer.extent.max_x, 5)
|
||||
|
@ -195,7 +195,7 @@ class DataSourceTest(unittest.TestCase):
|
|||
for k, v in source.fields.items():
|
||||
# Making sure we get the proper OGR Field instance, using
|
||||
# a string value index for the feature.
|
||||
self.assertEqual(True, isinstance(feat[k], v))
|
||||
self.assertIsInstance(feat[k], v)
|
||||
|
||||
# Testing Feature.__iter__
|
||||
for fld in feat:
|
||||
|
|
|
@ -205,7 +205,7 @@ class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
|||
# TestImageField value will default to being an instance of its
|
||||
# attr_class, a TestImageFieldFile, with name == None, which will
|
||||
# cause it to evaluate as False.
|
||||
self.assertEqual(isinstance(p.mugshot, TestImageFieldFile), True)
|
||||
self.assertIsInstance(p.mugshot, TestImageFieldFile)
|
||||
self.assertEqual(bool(p.mugshot), False)
|
||||
|
||||
# Test setting a fresh created model instance.
|
||||
|
@ -227,7 +227,7 @@ class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
|||
name (name set to None).
|
||||
"""
|
||||
p = self.PersonModel()
|
||||
self.assertEqual(isinstance(p.mugshot, TestImageFieldFile), True)
|
||||
self.assertIsInstance(p.mugshot, TestImageFieldFile)
|
||||
self.assertEqual(bool(p.mugshot), False)
|
||||
|
||||
def test_assignment_to_None(self):
|
||||
|
|
Loading…
Reference in New Issue