Permalink
Browse files

Used skipUnless decorator to skip tests in geos tests.

  • Loading branch information...
claudep committed Jun 4, 2012
1 parent f699641 commit 5ef599c7b32a238bfda6f56cd149bacb61b85c77
Showing with 7 additions and 7 deletions.
  1. +7 −7 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.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 @@ def test_ewkt(self):
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 @@ def test_collections_of_collections(self):
# 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 @@ def test_copy(self):
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 @@ def get_geoms(lst, srid=None):
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 @@ def test_line_merge(self):
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)

0 comments on commit 5ef599c

Please sign in to comment.