diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index 820cdfa..f3641d5 100644
a
|
b
|
class ListMixin(object):
|
152 | 152 | for i in range(len(self)): |
153 | 153 | try: |
154 | 154 | c = self[i] == other[i] |
155 | | except IndexError: |
| 155 | except (IndexError, self._IndexError): |
156 | 156 | # must be other is shorter |
157 | 157 | return False |
158 | 158 | if not c: |
159 | 159 | return False |
160 | | return True |
| 160 | return len(self) == len(other) |
161 | 161 | |
162 | 162 | def __lt__(self, other): |
163 | 163 | slen = len(self) |
164 | 164 | for i in range(slen): |
165 | 165 | try: |
166 | 166 | c = self[i] < other[i] |
167 | | except IndexError: |
| 167 | except (IndexError, self._IndexError): |
168 | 168 | # must be other is shorter |
169 | 169 | return False |
170 | 170 | if c: |
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 283daa4..ff548a1 100644
a
|
b
|
class GEOSTest(unittest.TestCase, TestDataMixin):
|
451 | 451 | self.assertEqual(poly.wkt, Polygon(*tuple(r for r in poly)).wkt) |
452 | 452 | self.assertEqual(poly.wkt, Polygon(*tuple(LinearRing(r.tuple) for r in poly)).wkt) |
453 | 453 | |
| 454 | def test_polygon_comparison(self): |
| 455 | p1 = Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))) |
| 456 | p2 = Polygon(((0, 0), (0, 1), (1, 0), (0, 0))) |
| 457 | self.assertTrue(p1 > p2) |
| 458 | self.assertFalse(p1 < p2) |
| 459 | |
454 | 460 | def test_multipolygons(self): |
455 | 461 | "Testing MultiPolygon objects." |
456 | 462 | prev = fromstr('POINT (0 0)') |
diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py
index 675505f..988d841 100644
a
|
b
|
class ListMixinTest(unittest.TestCase):
|
363 | 363 | |
364 | 364 | pl, ul = self.lists_of_len() |
365 | 365 | self.assertEqual(pl, ul, 'cmp for equal') |
| 366 | self.assertFalse(ul == pl + [2], 'cmp for not equal') |
366 | 367 | self.assertTrue(pl >= ul, 'cmp for gte self') |
367 | 368 | self.assertTrue(pl <= ul, 'cmp for lte self') |
368 | 369 | self.assertTrue(ul >= pl, 'cmp for self gte') |
… |
… |
class ListMixinTest(unittest.TestCase):
|
377 | 378 | self.assertTrue(ul < pl + [2], 'cmp') |
378 | 379 | self.assertTrue(ul <= pl + [2], 'cmp') |
379 | 380 | |
| 381 | # Also works with a custom IndexError |
| 382 | ul_longer = ul + [2] |
| 383 | ul_longer._IndexError = TypeError |
| 384 | ul._IndexError = TypeError |
| 385 | self.assertFalse(ul_longer == pl) |
| 386 | self.assertFalse(ul == ul_longer) |
| 387 | self.assertTrue(ul_longer > ul) |
| 388 | |
380 | 389 | pl[1] = 20 |
381 | 390 | self.assertTrue(pl > ul, 'cmp for gt self') |
382 | 391 | self.assertTrue(ul < pl, 'cmp for self lt') |