Ticket #19366: 19366-2.diff
File 19366-2.diff, 3.5 KB (added by , 12 years ago) |
---|
-
django/contrib/gis/geos/mutable_list.py
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 820cdfa..a009155 100644
a b class ListMixin(object): 149 149 return self 150 150 151 151 def __eq__(self, other): 152 for i in range(len(self)): 152 olen = len(other) 153 for i in range(olen): 153 154 try: 154 155 c = self[i] == other[i] 155 except IndexError:156 # must be other isshorter156 except self._IndexError: 157 # self must be shorter 157 158 return False 158 159 if not c: 159 160 return False 160 return True161 return len(self) == olen 161 162 162 163 def __lt__(self, other): 163 slen = len(self)164 for i in range( slen):164 olen = len(other) 165 for i in range(olen): 165 166 try: 166 167 c = self[i] < other[i] 167 except IndexError:168 except self._IndexError: 168 169 # must be other is shorter 169 170 return False 170 171 if c: 171 172 return c 172 return slen < len(other)173 return len(self) < olen 173 174 174 175 ### Public list interface Methods ### 175 176 ## Non-mutating ## -
django/contrib/gis/geos/tests/test_geos.py
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 283daa4..254794a 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 460 p3 = Polygon(((0, 0), (0, 1), (1, 1), (2, 0), (0, 0))) 461 p4 = Polygon(((0, 0), (0, 1), (2, 2), (1, 0), (0, 0))) 462 self.assertFalse(p4 < p3) 463 self.assertTrue(p3 < p4) 464 self.assertTrue(p4 > p3) 465 self.assertFalse(p3 > p4) 466 454 467 def test_multipolygons(self): 455 468 "Testing MultiPolygon objects." 456 469 prev = fromstr('POINT (0 0)') -
django/contrib/gis/geos/tests/test_mutable_list.py
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')