diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-06-04 20:39:54 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-06-04 20:39:54 +0200 |
| commit | 5ef599c7b32a238bfda6f56cd149bacb61b85c77 (patch) | |
| tree | 1c246b869887472facf2c7496338fce8d3231efe | |
| parent | f699641161a4ec8b6cbee938fd3a4379e7889ff2 (diff) | |
Used skipUnless decorator to skip tests in geos tests.
| -rw-r--r-- | django/contrib/gis/geos/tests/test_geos.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 9946495f54..f435cdaff1 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -1,6 +1,5 @@ import ctypes import random -import unittest from django.contrib.gis.geos import (GEOSException, GEOSIndexError, GEOSGeometry, GeometryCollection, Point, MultiPoint, Polygon, MultiPolygon, LinearRing, @@ -9,6 +8,8 @@ from django.contrib.gis.geos.base import gdal, numpy, GEOSBase from django.contrib.gis.geos.libgeos import GEOS_PREPARE from django.contrib.gis.geometry.test_data import TestDataMixin +from django.utils import unittest + class GEOSTest(unittest.TestCase, TestDataMixin): @@ -195,9 +196,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual(srid, poly.shell.srid) self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export + @unittest.skipUnless(gdal.HAS_GDAL and gdal.GEOJSON, "gdal >= 1.5 is required") def test_json(self): "Testing GeoJSON input/output (via GDAL)." - if not gdal or not gdal.GEOJSON: return for g in self.geometries.json_geoms: geom = GEOSGeometry(g.wkt) if not hasattr(g, 'not_equal'): @@ -813,9 +814,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # And, they should be equal. self.assertEqual(gc1, gc2) + @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required") def test_gdal(self): "Testing `ogr` and `srs` properties." - if not gdal.HAS_GDAL: return g1 = fromstr('POINT(5 23)') self.assertEqual(True, isinstance(g1.ogr, gdal.OGRGeometry)) self.assertEqual(g1.srs, None) @@ -835,9 +836,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertNotEqual(poly._ptr, cpy1._ptr) self.assertNotEqual(poly._ptr, cpy2._ptr) + @unittest.skipUnless(gdal.HAS_GDAL, "gdal is required") def test_transform(self): "Testing `transform` method." - if not gdal.HAS_GDAL: return orig = GEOSGeometry('POINT (-104.609 38.255)', 4326) trans = GEOSGeometry('POINT (992385.4472045 481455.4944650)', 2774) @@ -963,9 +964,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual(geom, tmpg) if not no_srid: self.assertEqual(geom.srid, tmpg.srid) + @unittest.skipUnless(GEOS_PREPARE, "geos >= 3.1.0 is required") def test_prepared(self): "Testing PreparedGeometry support." - if not GEOS_PREPARE: return # Creating a simple multipolygon and getting a prepared version. mpoly = GEOSGeometry('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))') prep = mpoly.prepared @@ -990,10 +991,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin): for geom, merged in zip(ref_geoms, ref_merged): self.assertEqual(merged, geom.merged) + @unittest.skipUnless(GEOS_PREPARE, "geos >= 3.1.0 is required") def test_valid_reason(self): "Testing IsValidReason support" - # Skipping tests if GEOS < v3.1. - if not GEOS_PREPARE: return g = GEOSGeometry("POINT(0 0)") self.assertTrue(g.valid) |
