Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

gis: Fixed #7873, `GEOSGeometry` equivalence comparison with `None` s…

…hould not raise an exception. Thanks, Denis.

git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8040 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bfe714f014d54f1f9bd67166b530006f740a820e 1 parent 825d6ed
@jbronn jbronn authored
View
4 django/contrib/gis/geos/base.py
@@ -166,8 +166,10 @@ def __eq__(self, other):
"""
if isinstance(other, basestring):
return self.wkt == other
- else:
+ elif isinstance(other, GEOSGeometry):
return self.equals_exact(other)
+ else:
+ return False
def __ne__(self, other):
"The not equals operator."
View
8 django/contrib/gis/tests/test_geos.py
@@ -107,13 +107,19 @@ def test01i_json(self):
self.assertEqual(GEOSGeometry(g.wkt), GEOSGeometry(geom.json))
def test01j_eq(self):
- "Testing equivalence with WKT."
+ "Testing equivalence."
p = fromstr('POINT(5 23)')
self.assertEqual(p, p.wkt)
self.assertNotEqual(p, 'foo')
ls = fromstr('LINESTRING(0 0, 1 1, 5 5)')
self.assertEqual(ls, ls.wkt)
self.assertNotEqual(p, 'bar')
+ # Error shouldn't be raise on equivalence testing with
+ # an invalid type.
+ for g in (p, ls):
+ self.assertNotEqual(g, None)
+ self.assertNotEqual(g, {'foo' : 'bar'})
+ self.assertNotEqual(g, False)
def test02a_points(self):
"Testing Point objects."
Please sign in to comment.
Something went wrong with that request. Please try again.