Skip to content

Commit 88601ba

Browse files
committed
Discovered some geodjango tests with standard mechanism
No need to special case tests discovery for regular first-level gis tests.
1 parent 4d46106 commit 88601ba

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

django/contrib/gis/tests/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from django.test.simple import build_suite, DjangoTestSuiteRunner
33
from django.utils import unittest
44

5+
from .test_geoforms import GeometryFieldTest
6+
from .test_measure import DistanceTest, AreaTest
7+
from .test_spatialrefsys import SpatialRefSysTest
8+
59

610
def geo_apps(namespace=True, runtests=False):
711
"""
@@ -54,20 +58,12 @@ def geodjango_suite(apps=True):
5458
from django.contrib.gis.geos import tests as geos_tests
5559
suite.addTest(geos_tests.suite())
5660

57-
# Adding the measurment tests.
58-
from django.contrib.gis.tests import test_measure
59-
suite.addTest(test_measure.suite())
60-
6161
# Adding GDAL tests, and any test suite that depends on GDAL, to the
6262
# suite if GDAL is available.
6363
from django.contrib.gis.gdal import HAS_GDAL
6464
if HAS_GDAL:
6565
from django.contrib.gis.gdal import tests as gdal_tests
6666
suite.addTest(gdal_tests.suite())
67-
68-
from django.contrib.gis.tests import test_spatialrefsys, test_geoforms
69-
suite.addTest(test_spatialrefsys.suite())
70-
suite.addTest(test_geoforms.suite())
7167
else:
7268
sys.stderr.write('GDAL not available - no tests requiring GDAL will be run.\n')
7369

django/contrib/gis/tests/test_geoforms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.forms import ValidationError
22
from django.contrib.gis import forms
3+
from django.contrib.gis.gdal import HAS_GDAL
34
from django.contrib.gis.geos import GEOSGeometry
45
from django.utils import unittest
56

67

8+
@unittest.skipUnless(HAS_GDAL, "GeometryFieldTest needs gdal support")
79
class GeometryFieldTest(unittest.TestCase):
810

911
def test00_init(self):

django/contrib/gis/tests/test_spatialrefsys.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.db import connection
2-
from django.contrib.gis.gdal import GDAL_VERSION
2+
from django.contrib.gis.gdal import HAS_GDAL
33
from django.contrib.gis.tests.utils import no_mysql, oracle, postgis, spatialite
44
from django.utils import unittest
55

@@ -35,6 +35,7 @@
3535
elif spatialite:
3636
from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
3737

38+
@unittest.skipUnless(HAS_GDAL, "SpatialRefSysTest needs gdal support")
3839
class SpatialRefSysTest(unittest.TestCase):
3940

4041
@no_mysql
@@ -65,6 +66,7 @@ def test01_retrieve(self):
6566
@no_mysql
6667
def test02_osr(self):
6768
"Testing getting OSR objects from SpatialRefSys model objects."
69+
from django.contrib.gis.gdal import GDAL_VERSION
6870
for sd in test_srs:
6971
sr = SpatialRefSys.objects.get(srid=sd['srid'])
7072
self.assertEqual(True, sr.spheroid.startswith(sd['spheroid']))

0 commit comments

Comments
 (0)