Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sanitized test assertions in gdal tests

  • Loading branch information...
commit 4b0f8d23c951c8f983fc849422c54d454f195b86 1 parent 1dae4ac
@claudep claudep authored
Showing with 23 additions and 22 deletions.
  1. +23 −22 django/contrib/gis/gdal/tests/test_geom.py
View
45 django/contrib/gis/gdal/tests/test_geom.py
@@ -38,19 +38,20 @@ def test00a_geomtype(self):
self.assertRaises(OGRException, OGRGeomType, 9)
# Equivalence can take strings, ints, and other OGRGeomTypes
- self.assertEqual(True, OGRGeomType(1) == OGRGeomType(1))
- self.assertEqual(True, OGRGeomType(7) == 'GeometryCollection')
- self.assertEqual(True, OGRGeomType('point') == 'POINT')
- self.assertEqual(False, OGRGeomType('point') == 2)
- self.assertEqual(True, OGRGeomType('unknown') == 0)
- self.assertEqual(True, OGRGeomType(6) == 'MULtiPolyGON')
- self.assertEqual(False, OGRGeomType(1) != OGRGeomType('point'))
- self.assertEqual(True, OGRGeomType('POINT') != OGRGeomType(6))
+ self.assertEqual(OGRGeomType(1), OGRGeomType(1))
+ self.assertEqual(OGRGeomType(7), 'GeometryCollection')
+ self.assertEqual(OGRGeomType('point'), 'POINT')
+ self.assertNotEqual(OGRGeomType('point'), 2)
+ self.assertEqual(OGRGeomType('unknown'), 0)
+ self.assertEqual(OGRGeomType(6), 'MULtiPolyGON')
+ self.assertEqual(OGRGeomType(1), OGRGeomType('point'))
+ self.assertNotEqual(OGRGeomType('POINT'), OGRGeomType(6))
# Testing the Django field name equivalent property.
self.assertEqual('PointField', OGRGeomType('Point').django)
+ self.assertEqual('GeometryField', OGRGeomType('Geometry').django)
self.assertEqual('GeometryField', OGRGeomType('Unknown').django)
- self.assertEqual(None, OGRGeomType('none').django)
+ self.assertIsNone(OGRGeomType('none').django)
# 'Geometry' initialization implies an unknown geometry type.
gt = OGRGeomType('Geometry')
@@ -60,8 +61,8 @@ def test00a_geomtype(self):
def test00b_geomtype_25d(self):
"Testing OGRGeomType object with 25D types."
wkb25bit = OGRGeomType.wkb25bit
- self.assertTrue(OGRGeomType(wkb25bit + 1) == 'Point25D')
- self.assertTrue(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
+ self.assertEqual(OGRGeomType(wkb25bit + 1), 'Point25D')
+ self.assertEqual(OGRGeomType('MultiLineString25D'), (5 + wkb25bit))
self.assertEqual('GeometryCollectionField', OGRGeomType('GeometryCollection25D').django)
def test01a_wkt(self):
@@ -159,8 +160,8 @@ def test04_linestring(self):
self.assertEqual('LINESTRING', linestr.geom_name)
self.assertEqual(ls.n_p, linestr.point_count)
self.assertEqual(ls.coords, linestr.tuple)
- self.assertEqual(True, linestr == OGRGeometry(ls.wkt))
- self.assertEqual(True, linestr != prev)
+ self.assertEqual(linestr, OGRGeometry(ls.wkt))
+ self.assertNotEqual(linestr, prev)
self.assertRaises(OGRIndexError, linestr.__getitem__, len(linestr))
prev = linestr
@@ -179,8 +180,8 @@ def test05_multilinestring(self):
self.assertEqual('MULTILINESTRING', mlinestr.geom_name)
self.assertEqual(mls.n_p, mlinestr.point_count)
self.assertEqual(mls.coords, mlinestr.tuple)
- self.assertEqual(True, mlinestr == OGRGeometry(mls.wkt))
- self.assertEqual(True, mlinestr != prev)
+ self.assertEqual(mlinestr, OGRGeometry(mls.wkt))
+ self.assertNotEqual(mlinestr, prev)
prev = mlinestr
for ls in mlinestr:
self.assertEqual(2, ls.geom_type)
@@ -195,8 +196,8 @@ def test06_linearring(self):
#self.assertEqual(101, lr.geom_type.num)
self.assertEqual('LINEARRING', lr.geom_name)
self.assertEqual(rr.n_p, len(lr))
- self.assertEqual(True, lr == OGRGeometry(rr.wkt))
- self.assertEqual(True, lr != prev)
+ self.assertEqual(lr, OGRGeometry(rr.wkt))
+ self.assertNotEqual(lr, prev)
prev = lr
def test07a_polygons(self):
@@ -222,8 +223,8 @@ def test07a_polygons(self):
self.assertAlmostEqual(p.centroid[1], y, 9)
# Testing equivalence
- self.assertEqual(True, poly == OGRGeometry(p.wkt))
- self.assertEqual(True, poly != prev)
+ self.assertEqual(poly, OGRGeometry(p.wkt))
+ self.assertNotEqual(poly, prev)
if p.ext_ring_cs:
ring = poly[0]
@@ -367,7 +368,7 @@ def test11_intersection(self):
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
i1 = OGRGeometry(self.geometries.intersect_geoms[i].wkt)
- self.assertEqual(True, a.intersects(b))
+ self.assertTrue(a.intersects(b))
i2 = a.intersection(b)
self.assertEqual(i1, i2)
self.assertEqual(i1, a & b) # __and__ is intersection operator
@@ -478,5 +479,5 @@ def test18_ogrgeometry_transform_workaround(self):
def test19_equivalence_regression(self):
"Testing equivalence methods with non-OGRGeometry instances."
- self.assertNotEqual(None, OGRGeometry('POINT(0 0)'))
- self.assertEqual(False, OGRGeometry('LINESTRING(0 0, 1 1)') == 3)
+ self.assertIsNotNone(OGRGeometry('POINT(0 0)'))
+ self.assertNotEqual(OGRGeometry('LINESTRING(0 0, 1 1)'), 3)
Please sign in to comment.
Something went wrong with that request. Please try again.