Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Justin Bronn authored July 22, 2008
4  django/contrib/gis/geos/base.py
@@ -166,8 +166,10 @@ def __eq__(self, other):
166 166
         """
167 167
         if isinstance(other, basestring):
168 168
             return self.wkt == other
169  
-        else:
  169
+        elif isinstance(other, GEOSGeometry):
170 170
             return self.equals_exact(other)
  171
+        else:
  172
+            return False
171 173
 
172 174
     def __ne__(self, other):
173 175
         "The not equals operator."
8  django/contrib/gis/tests/test_geos.py
@@ -107,13 +107,19 @@ def test01i_json(self):
107 107
             self.assertEqual(GEOSGeometry(g.wkt), GEOSGeometry(geom.json))
108 108
 
109 109
     def test01j_eq(self):
110  
-        "Testing equivalence with WKT."
  110
+        "Testing equivalence."
111 111
         p = fromstr('POINT(5 23)')
112 112
         self.assertEqual(p, p.wkt)
113 113
         self.assertNotEqual(p, 'foo')
114 114
         ls = fromstr('LINESTRING(0 0, 1 1, 5 5)')
115 115
         self.assertEqual(ls, ls.wkt)
116 116
         self.assertNotEqual(p, 'bar')
  117
+        # Error shouldn't be raise on equivalence testing with 
  118
+        # an invalid type.
  119
+        for g in (p, ls):
  120
+            self.assertNotEqual(g, None)
  121
+            self.assertNotEqual(g, {'foo' : 'bar'})
  122
+            self.assertNotEqual(g, False)
117 123
 
118 124
     def test02a_points(self):
119 125
         "Testing Point objects."

0 notes on commit bfe714f

Please sign in to comment.
Something went wrong with that request. Please try again.