Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Skip GeometryFieldTest if there's no spacial database.

  • Loading branch information...
commit 1794e36fa1facef40638f59012c2dac4ac4fa261 1 parent 5bdd0d6
@jphalip jphalip authored
View
24 django/contrib/gis/gdal/__init__.py
@@ -6,7 +6,7 @@
reference system to another.
Driver: Wraps an OGR data source driver.
-
+
DataSource: Wrapper for the OGR data source object, supports
OGR-supported data sources.
@@ -20,15 +20,15 @@
SpatialReference: Represents OSR Spatial Reference objects.
- The GDAL library will be imported from the system path using the default
+ The GDAL library will be imported from the system path using the default
library name for the current OS. The default library path may be overridden
- by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
- library on your system.
+ by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
+ library on your system.
- GDAL links to a large number of external libraries that consume RAM when
+ GDAL links to a large number of external libraries that consume RAM when
loaded. Thus, it may desirable to disable GDAL on systems with limited
RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH`
- to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`;
+ to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`;
setting to None/False/'' will not work as a string must be given).
"""
# Attempting to import objects that depend on the GDAL library. The
@@ -44,6 +44,18 @@
except:
HAS_GDAL, GEOJSON = False, False
+from django.contrib.gis.tests.utils import no_mysql, oracle, postgis, spatialite
+HAS_SPATIALREFSYS = True
+if oracle:
+ from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
+elif postgis:
+ from django.contrib.gis.db.backends.postgis.models import SpatialRefSys
+elif spatialite:
+ from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
+else:
+ HAS_SPATIALREFSYS = False
+ SpatialRefSys = None
+
try:
from django.contrib.gis.gdal.envelope import Envelope
except ImportError:
View
10 django/contrib/gis/tests/test_geoforms.py
@@ -1,11 +1,13 @@
from django.forms import ValidationError
-from django.contrib.gis import forms
-from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geos import GEOSGeometry
+from django.contrib.gis.gdal import HAS_GDAL, HAS_SPATIALREFSYS
from django.utils import unittest
-@unittest.skipUnless(HAS_GDAL, "GeometryFieldTest needs gdal support")
+if HAS_SPATIALREFSYS:
+ from django.contrib.gis import forms
+ from django.contrib.gis.geos import GEOSGeometry
+
+@unittest.skipUnless(HAS_GDAL and HAS_SPATIALREFSYS, "GeometryFieldTest needs gdal support and a spatial database")
class GeometryFieldTest(unittest.TestCase):
def test00_init(self):
View
12 django/contrib/gis/tests/test_spatialrefsys.py
@@ -1,5 +1,5 @@
from django.db import connection
-from django.contrib.gis.gdal import HAS_GDAL
+from django.contrib.gis.gdal import HAS_GDAL, HAS_SPATIALREFSYS, SpatialRefSys
from django.contrib.gis.tests.utils import no_mysql, oracle, postgis, spatialite
from django.utils import unittest
@@ -28,16 +28,6 @@
},
)
-HAS_SPATIALREFSYS = True
-if oracle:
- from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
-elif postgis:
- from django.contrib.gis.db.backends.postgis.models import SpatialRefSys
-elif spatialite:
- from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
-else:
- HAS_SPATIALREFSYS = False
-
@unittest.skipUnless(HAS_GDAL and HAS_SPATIALREFSYS,
"SpatialRefSysTest needs gdal support and a spatial database")
class SpatialRefSysTest(unittest.TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.