diff --git a/tests/datatypes/tests.py b/tests/datatypes/tests.py index 4b21d4e6e2..a69855da1f 100644 --- a/tests/datatypes/tests.py +++ b/tests/datatypes/tests.py @@ -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) diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py index 6c66a415df..d8c6e01884 100644 --- a/tests/defer_regress/tests.py +++ b/tests/defer_regress/tests.py @@ -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, ()) diff --git a/tests/dispatch/tests.py b/tests/dispatch/tests.py index 1860ca0614..a50d31cabe 100644 --- a/tests/dispatch/tests.py +++ b/tests/dispatch/tests.py @@ -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) diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index faedd1783c..19cf0fd9d0 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -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, '') diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index c713b1bf5b..0973d31a19 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -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.'], diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py index a0dcfb53e4..c9cb17fc9c 100644 --- a/tests/gis_tests/gdal_tests/test_ds.py +++ b/tests/gis_tests/gdal_tests/test_ds.py @@ -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: diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py index 7389573a16..c2908b06e4 100644 --- a/tests/model_fields/test_imagefield.py +++ b/tests/model_fields/test_imagefield.py @@ -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):