From d60d7d6d71018b17f01bbf0c390c7d929ff28310 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 1 Jun 2018 22:31:46 -0400 Subject: [PATCH] [1.11.x] Fixed #29462 -- Fixed ogrinspect test failures with GDAL 2.2. Backport of 55f4eee75d41499995bfdb611ac89e80c87404eb from master --- tests/gis_tests/inspectapp/tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index f971c85548..1e153fe772 100644 --- a/tests/gis_tests/inspectapp/tests.py +++ b/tests/gis_tests/inspectapp/tests.py @@ -62,6 +62,7 @@ class InspectDbTests(TestCase): INSTALLED_APPS={'append': 'django.contrib.gis'}, ) class OGRInspectTest(TestCase): + expected_srid = 'srid=-1' if GDAL_VERSION < (2, 2) else '' maxDiff = 1024 def test_poly(self): @@ -76,7 +77,7 @@ class OGRInspectTest(TestCase): ' float = models.FloatField()', ' int = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'), ' str = models.CharField(max_length=80)', - ' geom = models.PolygonField(srid=-1)', + ' geom = models.PolygonField(%s)' % self.expected_srid, ] self.assertEqual(model_def, '\n'.join(expected)) @@ -84,7 +85,7 @@ class OGRInspectTest(TestCase): def test_poly_multi(self): shp_file = os.path.join(TEST_DATA, 'test_poly', 'test_poly.shp') model_def = ogrinspect(shp_file, 'MyModel', multi_geom=True) - self.assertIn('geom = models.MultiPolygonField(srid=-1)', model_def) + self.assertIn('geom = models.MultiPolygonField(%s)' % self.expected_srid, model_def) # Same test with a 25D-type geometry field shp_file = os.path.join(TEST_DATA, 'gas_lines', 'gas_leitung.shp') model_def = ogrinspect(shp_file, 'MyModel', multi_geom=True) @@ -103,7 +104,7 @@ class OGRInspectTest(TestCase): ' population = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'), ' density = models.FloatField()', ' created = models.DateField()', - ' geom = models.PointField(srid=-1)', + ' geom = models.PointField(%s)' % self.expected_srid, ] self.assertEqual(model_def, '\n'.join(expected))