Used skipUnless decorator to skip tests in geos tests.
This commit is contained in:
parent
f699641161
commit
5ef599c7b3
|
@ -1,6 +1,5 @@
|
||||||
import ctypes
|
import ctypes
|
||||||
import random
|
import random
|
||||||
import unittest
|
|
||||||
|
|
||||||
from django.contrib.gis.geos import (GEOSException, GEOSIndexError, GEOSGeometry,
|
from django.contrib.gis.geos import (GEOSException, GEOSIndexError, GEOSGeometry,
|
||||||
GeometryCollection, Point, MultiPoint, Polygon, MultiPolygon, LinearRing,
|
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.geos.libgeos import GEOS_PREPARE
|
||||||
from django.contrib.gis.geometry.test_data import TestDataMixin
|
from django.contrib.gis.geometry.test_data import TestDataMixin
|
||||||
|
|
||||||
|
from django.utils import unittest
|
||||||
|
|
||||||
|
|
||||||
class GEOSTest(unittest.TestCase, TestDataMixin):
|
class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
|
|
||||||
|
@ -195,9 +196,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertEqual(srid, poly.shell.srid)
|
self.assertEqual(srid, poly.shell.srid)
|
||||||
self.assertEqual(srid, fromstr(poly.ewkt).srid) # Checking export
|
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):
|
def test_json(self):
|
||||||
"Testing GeoJSON input/output (via GDAL)."
|
"Testing GeoJSON input/output (via GDAL)."
|
||||||
if not gdal or not gdal.GEOJSON: return
|
|
||||||
for g in self.geometries.json_geoms:
|
for g in self.geometries.json_geoms:
|
||||||
geom = GEOSGeometry(g.wkt)
|
geom = GEOSGeometry(g.wkt)
|
||||||
if not hasattr(g, 'not_equal'):
|
if not hasattr(g, 'not_equal'):
|
||||||
|
@ -813,9 +814,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
# And, they should be equal.
|
# And, they should be equal.
|
||||||
self.assertEqual(gc1, gc2)
|
self.assertEqual(gc1, gc2)
|
||||||
|
|
||||||
|
@unittest.skipUnless(gdal.HAS_GDAL, "gdal is required")
|
||||||
def test_gdal(self):
|
def test_gdal(self):
|
||||||
"Testing `ogr` and `srs` properties."
|
"Testing `ogr` and `srs` properties."
|
||||||
if not gdal.HAS_GDAL: return
|
|
||||||
g1 = fromstr('POINT(5 23)')
|
g1 = fromstr('POINT(5 23)')
|
||||||
self.assertEqual(True, isinstance(g1.ogr, gdal.OGRGeometry))
|
self.assertEqual(True, isinstance(g1.ogr, gdal.OGRGeometry))
|
||||||
self.assertEqual(g1.srs, None)
|
self.assertEqual(g1.srs, None)
|
||||||
|
@ -835,9 +836,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertNotEqual(poly._ptr, cpy1._ptr)
|
self.assertNotEqual(poly._ptr, cpy1._ptr)
|
||||||
self.assertNotEqual(poly._ptr, cpy2._ptr)
|
self.assertNotEqual(poly._ptr, cpy2._ptr)
|
||||||
|
|
||||||
|
@unittest.skipUnless(gdal.HAS_GDAL, "gdal is required")
|
||||||
def test_transform(self):
|
def test_transform(self):
|
||||||
"Testing `transform` method."
|
"Testing `transform` method."
|
||||||
if not gdal.HAS_GDAL: return
|
|
||||||
orig = GEOSGeometry('POINT (-104.609 38.255)', 4326)
|
orig = GEOSGeometry('POINT (-104.609 38.255)', 4326)
|
||||||
trans = GEOSGeometry('POINT (992385.4472045 481455.4944650)', 2774)
|
trans = GEOSGeometry('POINT (992385.4472045 481455.4944650)', 2774)
|
||||||
|
|
||||||
|
@ -963,9 +964,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
self.assertEqual(geom, tmpg)
|
self.assertEqual(geom, tmpg)
|
||||||
if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
|
if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
|
||||||
|
|
||||||
|
@unittest.skipUnless(GEOS_PREPARE, "geos >= 3.1.0 is required")
|
||||||
def test_prepared(self):
|
def test_prepared(self):
|
||||||
"Testing PreparedGeometry support."
|
"Testing PreparedGeometry support."
|
||||||
if not GEOS_PREPARE: return
|
|
||||||
# Creating a simple multipolygon and getting a prepared version.
|
# 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)))')
|
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
|
prep = mpoly.prepared
|
||||||
|
@ -990,10 +991,9 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
for geom, merged in zip(ref_geoms, ref_merged):
|
for geom, merged in zip(ref_geoms, ref_merged):
|
||||||
self.assertEqual(merged, geom.merged)
|
self.assertEqual(merged, geom.merged)
|
||||||
|
|
||||||
|
@unittest.skipUnless(GEOS_PREPARE, "geos >= 3.1.0 is required")
|
||||||
def test_valid_reason(self):
|
def test_valid_reason(self):
|
||||||
"Testing IsValidReason support"
|
"Testing IsValidReason support"
|
||||||
# Skipping tests if GEOS < v3.1.
|
|
||||||
if not GEOS_PREPARE: return
|
|
||||||
|
|
||||||
g = GEOSGeometry("POINT(0 0)")
|
g = GEOSGeometry("POINT(0 0)")
|
||||||
self.assertTrue(g.valid)
|
self.assertTrue(g.valid)
|
||||||
|
|
Loading…
Reference in New Issue