summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2017-09-04 02:19:37 +0100
committerTim Graham <timograham@gmail.com>2017-09-03 21:19:37 -0400
commit9397d3add47f220249c8e543c79489618aaf50d6 (patch)
tree79b44be15dc3325f22af20e113c1cd8b39376dd3 /tests
parentfeb1a0a6922885eb0967428adf39fea9e4170ff8 (diff)
Fixed #28558 -- Simplified code to remove OGRIndexError.
The test is a regression for refs #4740 to show that the original fix of OGRIndexError is no longer needed. This is similar to the removal of GEOSIndexError in 197b1878105504b5ac7e399e1f52a6093c88baa3.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/gdal_tests/test_ds.py7
-rw-r--r--tests/gis_tests/gdal_tests/test_geom.py19
2 files changed, 17 insertions, 9 deletions
diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py
index 535aba70fb..b0ebcba840 100644
--- a/tests/gis_tests/gdal_tests/test_ds.py
+++ b/tests/gis_tests/gdal_tests/test_ds.py
@@ -4,7 +4,6 @@ import unittest
from django.contrib.gis.gdal import (
GDAL_VERSION, DataSource, Envelope, GDALException, OGRGeometry,
- OGRIndexError,
)
from django.contrib.gis.gdal.field import OFTInteger, OFTReal, OFTString
@@ -84,7 +83,7 @@ class DataSourceTest(unittest.TestCase):
self.assertEqual(source.driver, str(ds.driver))
# Making sure indexing works
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
ds[len(ds)]
def test02_invalid_shp(self):
@@ -120,9 +119,9 @@ class DataSourceTest(unittest.TestCase):
self.assertIn(f, source.fields)
# Negative FIDs are not allowed.
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
layer.__getitem__(-1)
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
layer.__getitem__(50000)
if hasattr(source, 'field_values'):
diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py
index 169857c0f2..aa1b371751 100644
--- a/tests/gis_tests/gdal_tests/test_geom.py
+++ b/tests/gis_tests/gdal_tests/test_geom.py
@@ -4,9 +4,10 @@ import unittest
from binascii import b2a_hex
from django.contrib.gis.gdal import (
- CoordTransform, GDALException, OGRGeometry, OGRGeomType, OGRIndexError,
- SpatialReference,
+ CoordTransform, GDALException, OGRGeometry, OGRGeomType, SpatialReference,
)
+from django.template import Context
+from django.template.engine import Engine
from ..test_data import TestDataMixin
@@ -157,7 +158,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
self.assertEqual(ls.coords, linestr.tuple)
self.assertEqual(linestr, OGRGeometry(ls.wkt))
self.assertNotEqual(linestr, prev)
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
linestr.__getitem__(len(linestr))
prev = linestr
@@ -182,7 +183,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
for ls in mlinestr:
self.assertEqual(2, ls.geom_type)
self.assertEqual('LINESTRING', ls.geom_name)
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
mlinestr.__getitem__(len(mlinestr))
def test_linearring(self):
@@ -232,6 +233,14 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
for r in poly:
self.assertEqual('LINEARRING', r.geom_name)
+ def test_polygons_templates(self):
+ # Accessing Polygon attributes in templates should work.
+ engine = Engine()
+ template = engine.from_string('{{ polygons.0.wkt }}')
+ polygons = [OGRGeometry(p.wkt) for p in self.geometries.multipolygons[:2]]
+ content = template.render(Context({'polygons': polygons}))
+ self.assertIn('MULTIPOLYGON (((100', content)
+
def test_closepolygons(self):
"Testing closing Polygon objects."
# Both rings in this geometry are not closed.
@@ -254,7 +263,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
if mp.valid:
self.assertEqual(mp.n_p, mpoly.point_count)
self.assertEqual(mp.num_geom, len(mpoly))
- with self.assertRaises(OGRIndexError):
+ with self.assertRaises(IndexError):
mpoly.__getitem__(len(mpoly))
for p in mpoly:
self.assertEqual('POLYGON', p.geom_name)