diff --git a/tests/delete/tests.py b/tests/delete/tests.py index 5330b4a13b..dd3c427824 100644 --- a/tests/delete/tests.py +++ b/tests/delete/tests.py @@ -37,7 +37,7 @@ class OnDeleteTests(TestCase): a = create_a('setnull') a.setnull.delete() a = A.objects.get(pk=a.pk) - self.assertEqual(None, a.setnull) + self.assertIsNone(a.setnull) def test_setdefault(self): a = create_a('setdefault') @@ -49,7 +49,7 @@ class OnDeleteTests(TestCase): a = create_a('setdefault_none') a.setdefault_none.delete() a = A.objects.get(pk=a.pk) - self.assertEqual(None, a.setdefault_none) + self.assertIsNone(a.setdefault_none) def test_cascade(self): a = create_a('cascade') @@ -119,7 +119,7 @@ class OnDeleteTests(TestCase): self.assertFalse(R.objects.filter(pk=a.child_setnull_id).exists()) a = A.objects.get(pk=a.pk) - self.assertEqual(None, a.child_setnull) + self.assertIsNone(a.child_setnull) def test_setnull_from_parent(self): a = create_a('child_setnull') @@ -127,13 +127,13 @@ class OnDeleteTests(TestCase): self.assertFalse(RChild.objects.filter(pk=a.child_setnull_id).exists()) a = A.objects.get(pk=a.pk) - self.assertEqual(None, a.child_setnull) + self.assertIsNone(a.child_setnull) def test_o2o_setnull(self): a = create_a('o2o_setnull') a.o2o_setnull.delete() a = A.objects.get(pk=a.pk) - self.assertEqual(None, a.o2o_setnull) + self.assertIsNone(a.o2o_setnull) class DeletionTests(TestCase): @@ -197,11 +197,11 @@ class DeletionTests(TestCase): a.cascade.delete() for obj in deleted: - self.assertEqual(None, obj.pk) + self.assertIsNone(obj.pk) for pk_list in related_setnull_sets: for a in A.objects.filter(id__in=pk_list): - self.assertEqual(None, a.setnull) + self.assertIsNone(a.setnull) models.signals.pre_delete.disconnect(pre_delete) diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index 19cf0fd9d0..aa26579a5b 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -186,9 +186,9 @@ class FieldsTests(SimpleTestCase): def test_integerfield_2(self): f = IntegerField(required=False) - self.assertEqual(None, f.clean('')) + self.assertIsNone(f.clean('')) self.assertEqual('None', repr(f.clean(''))) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean(None)) self.assertEqual('None', repr(f.clean(None))) self.assertEqual(1, f.clean('1')) self.assertIsInstance(f.clean('1'), int) @@ -301,8 +301,8 @@ class FieldsTests(SimpleTestCase): def test_floatfield_2(self): f = FloatField(required=False) - self.assertEqual(None, f.clean('')) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean('')) + self.assertIsNone(f.clean(None)) self.assertEqual(1.0, f.clean('1')) self.assertEqual(f.max_value, None) self.assertEqual(f.min_value, None) @@ -379,8 +379,8 @@ class FieldsTests(SimpleTestCase): def test_decimalfield_2(self): f = DecimalField(max_digits=4, decimal_places=2, required=False) - self.assertEqual(None, f.clean('')) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean('')) + self.assertIsNone(f.clean(None)) self.assertEqual(f.clean('1'), Decimal("1")) self.assertEqual(f.max_digits, 4) self.assertEqual(f.decimal_places, 2) @@ -483,9 +483,9 @@ class FieldsTests(SimpleTestCase): def test_datefield_2(self): f = DateField(required=False) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean(None)) self.assertEqual('None', repr(f.clean(None))) - self.assertEqual(None, f.clean('')) + self.assertIsNone(f.clean('')) self.assertEqual('None', repr(f.clean(''))) def test_datefield_3(self): @@ -604,9 +604,9 @@ class FieldsTests(SimpleTestCase): def test_datetimefield_3(self): f = DateTimeField(required=False) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean(None)) self.assertEqual('None', repr(f.clean(None))) - self.assertEqual(None, f.clean('')) + self.assertIsNone(f.clean('')) self.assertEqual('None', repr(f.clean(''))) def test_datetimefield_4(self): @@ -1075,7 +1075,7 @@ class FieldsTests(SimpleTestCase): def test_typedchoicefield_6(self): f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None) - self.assertEqual(None, f.clean('')) + self.assertIsNone(f.clean('')) def test_typedchoicefield_has_changed(self): # has_changed should not trigger required validation @@ -1104,15 +1104,15 @@ class FieldsTests(SimpleTestCase): def test_nullbooleanfield_1(self): f = NullBooleanField() - self.assertEqual(None, f.clean('')) + self.assertIsNone(f.clean('')) self.assertEqual(True, f.clean(True)) self.assertEqual(False, f.clean(False)) - self.assertEqual(None, f.clean(None)) + self.assertIsNone(f.clean(None)) self.assertEqual(False, f.clean('0')) self.assertEqual(True, f.clean('1')) - self.assertEqual(None, f.clean('2')) - self.assertEqual(None, f.clean('3')) - self.assertEqual(None, f.clean('hello')) + self.assertIsNone(f.clean('2')) + self.assertIsNone(f.clean('3')) + self.assertIsNone(f.clean('hello')) self.assertEqual(True, f.clean('true')) self.assertEqual(False, f.clean('false')) @@ -1129,7 +1129,7 @@ class FieldsTests(SimpleTestCase): hidden_nullbool1 = NullBooleanField(widget=HiddenInput, initial=True) hidden_nullbool2 = NullBooleanField(widget=HiddenInput, initial=False) f = HiddenNullBooleanForm({'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False'}) - self.assertEqual(None, f.full_clean()) + self.assertIsNone(f.full_clean()) self.assertEqual(True, f.cleaned_data['hidden_nullbool1']) self.assertEqual(False, f.cleaned_data['hidden_nullbool2']) @@ -1143,10 +1143,10 @@ class FieldsTests(SimpleTestCase): nullbool1 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES)) nullbool2 = NullBooleanField(widget=RadioSelect(choices=NULLBOOL_CHOICES)) f = MySQLNullBooleanForm({'nullbool0': '1', 'nullbool1': '0', 'nullbool2': ''}) - self.assertEqual(None, f.full_clean()) + self.assertIsNone(f.full_clean()) self.assertEqual(True, f.cleaned_data['nullbool0']) self.assertEqual(False, f.cleaned_data['nullbool1']) - self.assertEqual(None, f.cleaned_data['nullbool2']) + self.assertIsNone(f.cleaned_data['nullbool2']) def test_nullbooleanfield_changed(self): f = NullBooleanField() @@ -1249,7 +1249,7 @@ class FieldsTests(SimpleTestCase): def test_typedmultiplechoicefield_7(self): # If you want cleaning an empty value to return a different type, tell the field f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int, required=False, empty_value=None) - self.assertEqual(None, f.clean([])) + self.assertIsNone(f.clean([])) def test_typedmultiplechoicefield_has_changed(self): # has_changed should not trigger required validation @@ -1402,10 +1402,10 @@ class FieldsTests(SimpleTestCase): f = SplitDateTimeField(required=False) self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean([datetime.date(2006, 1, 10), datetime.time(7, 30)])) self.assertEqual(datetime.datetime(2006, 1, 10, 7, 30), f.clean(['2006-01-10', '07:30'])) - self.assertEqual(None, f.clean(None)) - self.assertEqual(None, f.clean('')) - self.assertEqual(None, f.clean([''])) - self.assertEqual(None, f.clean(['', ''])) + self.assertIsNone(f.clean(None)) + self.assertIsNone(f.clean('')) + self.assertIsNone(f.clean([''])) + self.assertIsNone(f.clean(['', ''])) self.assertRaisesMessage(ValidationError, "'Enter a list of values.'", f.clean, 'hello') six.assertRaisesRegex(self, ValidationError, "'Enter a valid date\.', u?'Enter a valid time\.'", f.clean, ['hello', 'there']) self.assertRaisesMessage(ValidationError, "'Enter a valid time.'", f.clean, ['2006-01-10', 'there']) diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 0973d31a19..6aedfa8507 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2104,9 +2104,9 @@ class FormsTestCase(TestCase): # Empty values for fields will NOT raise a `required` error on an # optional `MultiValueField` f = PhoneField(required=False) - self.assertEqual(None, f.clean('')) - self.assertEqual(None, f.clean(None)) - self.assertEqual(None, f.clean([])) + self.assertIsNone(f.clean('')) + self.assertIsNone(f.clean(None)) + self.assertIsNone(f.clean([])) self.assertEqual('+61. ext. (label: )', f.clean(['+61'])) self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) self.assertEqual('+61.287654321 ext. 123 (label: Home)', f.clean(['+61', '287654321', '123', 'Home'])) @@ -2131,9 +2131,9 @@ class FormsTestCase(TestCase): # For an optional `MultiValueField` with `require_all_fields=False`, we # don't get any `required` error but we still get `incomplete` errors. f = PhoneField(required=False, require_all_fields=False) - self.assertEqual(None, f.clean('')) - self.assertEqual(None, f.clean(None)) - self.assertEqual(None, f.clean([])) + self.assertIsNone(f.clean('')) + self.assertIsNone(f.clean(None)) + self.assertIsNone(f.clean([])) self.assertRaisesMessage(ValidationError, "'Enter a complete value.'", f.clean, ['+61']) self.assertEqual('+61.287654321 ext. 123 (label: )', f.clean(['+61', '287654321', '123'])) six.assertRaisesRegex(self, ValidationError, diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index 8e8aa82cdd..6dafee1fb8 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -334,7 +334,7 @@ class EmptyLabelTestCase(TestCase): def test_get_display_value_on_none(self): m = ChoiceModel.objects.create(name='test', choice='', choice_integer=None) - self.assertEqual(None, m.choice_integer) + self.assertIsNone(m.choice_integer) self.assertEqual('No Preference', m.get_choice_integer_display()) def test_html_rendering_of_prepopulated_models(self): diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py index 64e1759a26..3950adb57f 100644 --- a/tests/generic_views/test_edit.py +++ b/tests/generic_views/test_edit.py @@ -35,7 +35,7 @@ class FormMixinTests(TestCase): request = get_request default_kwargs = TestFormMixin().get_form_kwargs() - self.assertEqual(None, default_kwargs.get('prefix')) + self.assertIsNone(default_kwargs.get('prefix')) set_mixin = TestFormMixin() set_mixin.prefix = test_string diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py index c9cb17fc9c..0de4c282b9 100644 --- a/tests/gis_tests/gdal_tests/test_ds.py +++ b/tests/gis_tests/gdal_tests/test_ds.py @@ -118,7 +118,7 @@ class DataSourceTest(unittest.TestCase): # Now checking the field names. flds = layer.fields for f in flds: - self.assertEqual(True, f in source.fields) + self.assertIn(f, source.fields) # Negative FIDs are not allowed. self.assertRaises(OGRIndexError, layer.__getitem__, -1) @@ -199,7 +199,7 @@ class DataSourceTest(unittest.TestCase): # Testing Feature.__iter__ for fld in feat: - self.assertEqual(True, fld.name in source.fields.keys()) + self.assertIn(fld.name, source.fields.keys()) def test05_geometries(self): "Testing Geometries from Data Source Features." @@ -229,7 +229,7 @@ class DataSourceTest(unittest.TestCase): lyr = ds[0] # When not set, it should be None. - self.assertEqual(None, lyr.spatial_filter) + self.assertIsNone(lyr.spatial_filter) # Must be set a/an OGRGeometry or 4-tuple. self.assertRaises(TypeError, lyr._set_spatial_filter, 'foo') diff --git a/tests/gis_tests/gdal_tests/test_srs.py b/tests/gis_tests/gdal_tests/test_srs.py index 1d011d88ab..98e4312786 100644 --- a/tests/gis_tests/gdal_tests/test_srs.py +++ b/tests/gis_tests/gdal_tests/test_srs.py @@ -255,4 +255,4 @@ class SpatialRefTest(unittest.TestCase): self.assertEqual('WGS_1984', s1['DATUM']) self.assertEqual('EPSG', s1['AUTHORITY']) self.assertEqual(4326, int(s1['AUTHORITY', 1])) - self.assertEqual(None, s1['FOOBAR']) + self.assertIsNone(s1['FOOBAR']) diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index c14a2782dc..b0843c9bd2 100644 --- a/tests/gis_tests/geos_tests/test_geos.py +++ b/tests/gis_tests/geos_tests/test_geos.py @@ -227,8 +227,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual(pnt.geom_typeid, 0) self.assertEqual(p.x, pnt.x) self.assertEqual(p.y, pnt.y) - self.assertEqual(True, pnt == fromstr(p.wkt)) - self.assertEqual(False, pnt == prev) + self.assertEqual(pnt, fromstr(p.wkt)) + self.assertEqual(False, pnt == prev) # Use assertEqual to test __eq__ # Making sure that the point's X, Y components are what we expect self.assertAlmostEqual(p.x, pnt.tuple[0], 9) @@ -244,7 +244,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): set_tup2 = (5.23, 2.71, 3.14) else: self.assertEqual(False, pnt.hasz) - self.assertEqual(None, pnt.z) + self.assertIsNone(pnt.z) tup_args = (p.x, p.y) set_tup1 = (2.71, 3.14) set_tup2 = (3.14, 2.71) @@ -255,8 +255,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # Now testing the different constructors pnt2 = Point(tup_args) # e.g., Point((1, 2)) pnt3 = Point(*tup_args) # e.g., Point(1, 2) - self.assertEqual(True, pnt == pnt2) - self.assertEqual(True, pnt == pnt3) + self.assertEqual(pnt, pnt2) + self.assertEqual(pnt, pnt3) # Now testing setting the x and y pnt.y = 3.14 @@ -305,8 +305,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): if hasattr(l, 'tup'): self.assertEqual(l.tup, ls.tuple) - self.assertEqual(True, ls == fromstr(l.wkt)) - self.assertEqual(False, ls == prev) + self.assertEqual(ls, fromstr(l.wkt)) + self.assertEqual(False, ls == prev) # Use assertEqual to test __eq__ self.assertRaises(GEOSIndexError, ls.__getitem__, len(ls)) prev = ls @@ -330,8 +330,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9) self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9) - self.assertEqual(True, ml == fromstr(l.wkt)) - self.assertEqual(False, ml == prev) + self.assertEqual(ml, fromstr(l.wkt)) + self.assertEqual(False, ml == prev) # Use assertEqual to test __eq__ prev = ml for ls in ml: @@ -394,9 +394,10 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertAlmostEqual(p.centroid[1], poly.centroid.tuple[1], 9) # Testing the geometry equivalence - self.assertEqual(True, poly == fromstr(p.wkt)) - self.assertEqual(False, poly == prev) # Should not be equal to previous geometry - self.assertEqual(True, poly != prev) + self.assertEqual(poly, fromstr(p.wkt)) + # Should not be equal to previous geometry + self.assertEqual(False, poly == prev) # Use assertEqual to test __eq__ + self.assertNotEqual(poly, prev) # Use assertNotEqual to test __ne__ # Testing the exterior ring ring = poly.exterior_ring diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py index 5422dd48a7..97c42b5dc3 100644 --- a/tests/gis_tests/relatedapp/tests.py +++ b/tests/gis_tests/relatedapp/tests.py @@ -288,7 +288,7 @@ class RelatedGeoModelTest(TestCase): Book.objects.create(title='Without Author') b = Book.objects.select_related('author').get(title='Without Author') # Should be `None`, and not a 'dummy' model. - self.assertEqual(None, b.author) + self.assertIsNone(b.author) @skipUnlessDBFeature("supports_collect_aggr") @ignore_warnings(category=RemovedInDjango20Warning) diff --git a/tests/gis_tests/test_geoip.py b/tests/gis_tests/test_geoip.py index 57647314b3..d456dca1bf 100644 --- a/tests/gis_tests/test_geoip.py +++ b/tests/gis_tests/test_geoip.py @@ -32,16 +32,16 @@ class GeoIPTest(unittest.TestCase): g3 = GeoIP.open(path, 0) # MaxMind Python API syntax. for g in (g1, g2, g3): - self.assertEqual(True, bool(g._country)) - self.assertEqual(True, bool(g._city)) + self.assertTrue(g._country) + self.assertTrue(g._city) # Only passing in the location of one database. city = os.path.join(path, 'GeoLiteCity.dat') cntry = os.path.join(path, 'GeoIP.dat') g4 = GeoIP(city, country='') - self.assertEqual(None, g4._country) + self.assertIsNone(g4._country) g5 = GeoIP(cntry, city='') - self.assertEqual(None, g5._city) + self.assertIsNone(g5._city) # Improper parameters. bad_params = (23, 'foo', 15.23) diff --git a/tests/gis_tests/test_spatialrefsys.py b/tests/gis_tests/test_spatialrefsys.py index 66e30f3de1..e0c593ff4a 100644 --- a/tests/gis_tests/test_spatialrefsys.py +++ b/tests/gis_tests/test_spatialrefsys.py @@ -56,7 +56,7 @@ class SpatialRefSysTest(unittest.TestCase): # the testing with the 'startswith' flag. auth_name, oracle_flag = sd['auth_name'] if postgis or (oracle and oracle_flag): - self.assertEqual(True, srs.auth_name.startswith(auth_name)) + self.assertTrue(srs.auth_name.startswith(auth_name)) self.assertEqual(sd['auth_srid'], srs.auth_srid) @@ -71,14 +71,14 @@ class SpatialRefSysTest(unittest.TestCase): """ for sd in test_srs: sr = SpatialRefSys.objects.get(srid=sd['srid']) - self.assertEqual(True, sr.spheroid.startswith(sd['spheroid'])) + self.assertTrue(sr.spheroid.startswith(sd['spheroid'])) self.assertEqual(sd['geographic'], sr.geographic) self.assertEqual(sd['projected'], sr.projected) if not (spatialite and not sd['spatialite']): # Can't get 'NAD83 / Texas South Central' from PROJ.4 string # on SpatiaLite - self.assertEqual(True, sr.name.startswith(sd['name'])) + self.assertTrue(sr.name.startswith(sd['name'])) # Testing the SpatialReference object directly. if postgis or spatialite: diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index d3daf6e183..0be38f27b8 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -131,13 +131,13 @@ class TranslationTests(TestCase): # It should be possible to compare *_lazy objects. s1 = ugettext_lazy('Add %(name)s') - self.assertEqual(True, s == s1) + self.assertEqual(s, s1) s2 = gettext_lazy('Add %(name)s') s3 = gettext_lazy('Add %(name)s') - self.assertEqual(True, s2 == s3) - self.assertEqual(True, s == s2) + self.assertEqual(s2, s3) + self.assertEqual(s, s2) s4 = ugettext_lazy('Some other string') - self.assertEqual(False, s == s4) + self.assertNotEqual(s, s4) @skipUnless(six.PY2, "No more bytestring translations on PY3") def test_lazy_and_bytestrings(self): @@ -540,7 +540,7 @@ class FormattingTests(TestCase): 'time_field': '20:50', 'integer_field': '1.234', }) - self.assertEqual(False, form.is_valid()) + self.assertFalse(form.is_valid()) self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['float_field']) self.assertEqual(['Introdu\xefu un n\xfamero.'], form.errors['decimal_field']) self.assertEqual(['Introdu\xefu una data v\xe0lida.'], form.errors['date_field']) @@ -552,7 +552,7 @@ class FormattingTests(TestCase): 'date_field_day': '31', 'date_field_year': '2009' }) - self.assertEqual(True, form2.is_valid()) + self.assertTrue(form2.is_valid()) self.assertEqual(datetime.date(2009, 12, 31), form2.cleaned_data['date_field']) self.assertHTMLEqual( '\n\n', @@ -627,7 +627,7 @@ class FormattingTests(TestCase): 'time_field': '20:50', 'integer_field': '1.234', }) - self.assertEqual(True, form3.is_valid()) + self.assertTrue(form3.is_valid()) self.assertEqual(decimal.Decimal('66666.666'), form3.cleaned_data['decimal_field']) self.assertEqual(99999.999, form3.cleaned_data['float_field']) self.assertEqual(datetime.date(2009, 12, 31), form3.cleaned_data['date_field']) @@ -657,7 +657,7 @@ class FormattingTests(TestCase): 'time_field': '20:50', 'integer_field': '1234', }) - self.assertEqual(True, form4.is_valid()) + self.assertTrue(form4.is_valid()) self.assertEqual(decimal.Decimal('66666.666'), form4.cleaned_data['decimal_field']) self.assertEqual(99999.999, form4.cleaned_data['float_field']) self.assertEqual(datetime.date(2009, 12, 31), form4.cleaned_data['date_field']) @@ -670,7 +670,7 @@ class FormattingTests(TestCase): 'date_field_day': '31', 'date_field_year': '2009' }) - self.assertEqual(True, form5.is_valid()) + self.assertTrue(form5.is_valid()) self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field']) self.assertHTMLEqual( '\n\n', @@ -729,7 +729,7 @@ class FormattingTests(TestCase): 'time_field': '20:50', 'integer_field': '1234', }) - self.assertEqual(True, form5.is_valid()) + self.assertTrue(form5.is_valid()) self.assertEqual(decimal.Decimal('66666.666'), form5.cleaned_data['decimal_field']) self.assertEqual(99999.999, form5.cleaned_data['float_field']) self.assertEqual(datetime.date(2009, 12, 31), form5.cleaned_data['date_field']) @@ -742,7 +742,7 @@ class FormattingTests(TestCase): 'date_field_day': '31', 'date_field_year': '2009' }) - self.assertEqual(True, form6.is_valid()) + self.assertTrue(form6.is_valid()) self.assertEqual(datetime.date(2009, 12, 31), form6.cleaned_data['date_field']) self.assertHTMLEqual( '\n\n', @@ -771,7 +771,7 @@ class FormattingTests(TestCase): 'cents_paid': decimal.Decimal('59.47'), 'products_delivered': 12000, }) - self.assertEqual(True, form6.is_valid()) + self.assertTrue(form6.is_valid()) self.assertHTMLEqual( form6.as_ul(), '
  • \n
  • \n
  • \n
  • ' diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index 46779626f8..bb19af263c 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -514,7 +514,7 @@ class ValidationTest(test.TestCase): def test_nullable_integerfield_cleans_none_on_null_and_blank_true(self): f = models.IntegerField(null=True, blank=True) - self.assertEqual(None, f.clean(None, None)) + self.assertIsNone(f.clean(None, None)) def test_integerfield_raises_error_on_empty_input(self): f = models.IntegerField(null=False) diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index 1ac6b3c590..299ada97b1 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -536,7 +536,7 @@ class QueryTestCase(TestCase): "ForeignKey.validate() uses the correct database" mickey = Person.objects.using('other').create(name="Mickey") pluto = Pet.objects.using('other').create(name="Pluto", owner=mickey) - self.assertEqual(None, pluto.full_clean()) + self.assertIsNone(pluto.full_clean()) def test_o2o_separation(self): "OneToOne fields are constrained to a single database" diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index 35b79f9dc4..cab7263af2 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -90,7 +90,7 @@ class TestSaveLoad(TestCase): instance = RangesModel(ints=None) instance.save() loaded = RangesModel.objects.get() - self.assertEqual(None, loaded.ints) + self.assertIsNone(loaded.ints) @skipUnlessPG92 diff --git a/tests/validation/test_validators.py b/tests/validation/test_validators.py index c3875d4601..d06605eeca 100644 --- a/tests/validation/test_validators.py +++ b/tests/validation/test_validators.py @@ -7,7 +7,7 @@ from .models import ModelToValidate class TestModelsWithValidators(ValidationTestCase): def test_custom_validator_passes_for_correct_value(self): mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42) - self.assertEqual(None, mtv.full_clean()) + self.assertIsNone(mtv.full_clean()) def test_custom_validator_raises_error_for_incorrect_value(self): mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12) diff --git a/tests/validation/tests.py b/tests/validation/tests.py index defd66edec..693d6b6c23 100644 --- a/tests/validation/tests.py +++ b/tests/validation/tests.py @@ -19,7 +19,7 @@ class BaseModelValidationTests(ValidationTestCase): def test_with_correct_value_model_validates(self): mtv = ModelToValidate(number=10, name='Some Name') - self.assertEqual(None, mtv.full_clean()) + self.assertIsNone(mtv.full_clean()) def test_custom_validate_method(self): mtv = ModelToValidate(number=11) @@ -37,7 +37,7 @@ class BaseModelValidationTests(ValidationTestCase): def test_correct_FK_value_validates(self): parent = ModelToValidate.objects.create(number=10, name='Some Name') mtv = ModelToValidate(number=10, name='Some Name', parent_id=parent.pk) - self.assertEqual(None, mtv.full_clean()) + self.assertIsNone(mtv.full_clean()) def test_limited_FK_raises_error(self): # The limit_choices_to on the parent field says that a parent object's @@ -52,7 +52,7 @@ class BaseModelValidationTests(ValidationTestCase): def test_correct_email_value_passes(self): mtv = ModelToValidate(number=10, name='Some Name', email='valid@email.com') - self.assertEqual(None, mtv.full_clean()) + self.assertIsNone(mtv.full_clean()) def test_wrong_url_value_raises_error(self): mtv = ModelToValidate(number=10, name='Some Name', url='not a url')