mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
gis: Fixed #7873, GEOSGeometry
equivalence comparison with None
should not raise an exception. Thanks, Denis.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8040 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
825d6edd69
commit
bfe714f014
@ -166,8 +166,10 @@ class GEOSGeometry(object):
|
||||
"""
|
||||
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."
|
||||
|
@ -107,13 +107,19 @@ class GEOSTest(unittest.TestCase):
|
||||
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."
|
||||
|
Loading…
x
Reference in New Issue
Block a user