summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/contrib/gis/gdal/__init__.py24
-rw-r--r--django/contrib/gis/tests/test_geoforms.py10
-rw-r--r--django/contrib/gis/tests/test_spatialrefsys.py12
3 files changed, 25 insertions, 21 deletions
diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py
index cc47ae9bc2..c62197f385 100644
--- a/django/contrib/gis/gdal/__init__.py
+++ b/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 @@ try:
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:
diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py
index 1af3dec5e9..913e2db975 100644
--- a/django/contrib/gis/tests/test_geoforms.py
+++ b/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):
diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py
index 6ce72b51f0..47e406066a 100644
--- a/django/contrib/gis/tests/test_spatialrefsys.py
+++ b/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 @@ test_srs = ({'srid' : 4326,
},
)
-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):