summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2021-09-24 10:15:23 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-27 09:58:28 +0200
commit4ffada36097ceccfd6f0d358217ac3c40d2a729c (patch)
tree314864f4c59f246d46ec4fd2b47d2d04ea7d85bb /tests
parentfb05ca420da1341c0d39cf1f0e2fb659be836c92 (diff)
Fixed #33136 -- Added GEOSGeometry.make_valid() method.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index ab809b6630..27208e005d 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -1429,6 +1429,25 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self.assertIsNone(g.normalize())
self.assertTrue(g.equals_exact(MultiPoint(Point(2, 2), Point(1, 1), Point(0, 0))))
+ @skipIf(geos_version_tuple() < (3, 8), 'GEOS >= 3.8.0 is required')
+ def test_make_valid(self):
+ poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 0, 23 23, 0 0))')
+ self.assertIs(poly.valid, False)
+ valid_poly = poly.make_valid()
+ self.assertIs(valid_poly.valid, True)
+ self.assertNotEqual(valid_poly, poly)
+
+ valid_poly2 = valid_poly.make_valid()
+ self.assertIs(valid_poly2.valid, True)
+ self.assertEqual(valid_poly, valid_poly2)
+
+ @mock.patch('django.contrib.gis.geos.libgeos.geos_version', lambda: b'3.7.3')
+ def test_make_valid_geos_version(self):
+ msg = 'GEOSGeometry.make_valid() requires GEOS >= 3.8.0.'
+ poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 0, 23 23, 0 0))')
+ with self.assertRaisesMessage(GEOSException, msg):
+ poly.make_valid()
+
def test_empty_point(self):
p = Point(srid=4326)
self.assertEqual(p.ogr.ewkt, p.ewkt)