diff options
author | Nick Pope <nick.pope@flightdataservices.com> | 2019-10-21 09:55:05 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-29 12:37:30 +0100 |
commit | 7552de7866dcd270a0f353b007b4aceaa7f3ff3e (patch) | |
tree | 2e84292833853d9659671ed304cb32d5acef5f90 /tests/gis_tests | |
parent | a6cb8ec3895a72bfb7f8e62d4b05dd5de6b738af (diff) | |
download | django-7552de7866dcd270a0f353b007b4aceaa7f3ff3e.tar.gz |
Used more specific unittest assertions in tests.
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r-- | tests/gis_tests/geos_tests/test_geos.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index c2aca95178..1f326b6774 100644 --- a/tests/gis_tests/geos_tests/test_geos.py +++ b/tests/gis_tests/geos_tests/test_geos.py @@ -183,9 +183,9 @@ class GEOSTest(SimpleTestCase, TestDataMixin): # Error shouldn't be raise on equivalence testing with # an invalid type. for g in (p, ls): - self.assertNotEqual(g, None) + self.assertIsNotNone(g) self.assertNotEqual(g, {'foo': 'bar'}) - self.assertNotEqual(g, False) + self.assertIsNot(g, False) def test_hash(self): point_1 = Point(5, 23) @@ -236,7 +236,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin): self.assertEqual(p.x, pnt.x) self.assertEqual(p.y, pnt.y) self.assertEqual(pnt, fromstr(p.wkt)) - self.assertEqual(False, pnt == prev) # Use assertEqual to test __eq__ + self.assertIs(pnt == prev, False) # Use assertIs() to test __eq__. # Making sure that the point's X, Y components are what we expect self.assertAlmostEqual(p.x, pnt.tuple[0], 9) @@ -323,7 +323,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin): self.assertEqual(l.tup, ls.tuple) self.assertEqual(ls, fromstr(l.wkt)) - self.assertEqual(False, ls == prev) # Use assertEqual to test __eq__ + self.assertIs(ls == prev, False) # Use assertIs() to test __eq__. with self.assertRaises(IndexError): ls.__getitem__(len(ls)) prev = ls @@ -399,7 +399,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin): self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9) self.assertEqual(ml, fromstr(l.wkt)) - self.assertEqual(False, ml == prev) # Use assertEqual to test __eq__ + self.assertIs(ml == prev, False) # Use assertIs() to test __eq__. prev = ml for ls in ml: @@ -483,8 +483,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin): # Testing the geometry equivalence 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__ + self.assertIs(poly == prev, False) # Use assertIs() to test __eq__. + self.assertIs(poly != prev, True) # Use assertIs() to test __ne__. # Testing the exterior ring ring = poly.exterior_ring |