diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-07-22 02:43:47 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-07-22 02:43:47 +0000 |
| commit | bfe714f014d54f1f9bd67166b530006f740a820e (patch) | |
| tree | 7e6c139c5b97c9bb3e47c6e76f5d77432f94e0bf | |
| parent | 825d6edd69404de29c6fb8be568176f03b0c982c (diff) | |
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
| -rw-r--r-- | django/contrib/gis/geos/base.py | 4 | ||||
| -rw-r--r-- | django/contrib/gis/tests/test_geos.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py index 728e99e2be..8200d59eec 100644 --- a/django/contrib/gis/geos/base.py +++ b/django/contrib/gis/geos/base.py @@ -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." diff --git a/django/contrib/gis/tests/test_geos.py b/django/contrib/gis/tests/test_geos.py index 15fdfb66ec..8ea450700c 100644 --- a/django/contrib/gis/tests/test_geos.py +++ b/django/contrib/gis/tests/test_geos.py @@ -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." |
