Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Trusted test skipping about gis tests running or not

With the new test discovery system, gis tests are discovered as
other tests. They should be properly skipped now when dependencies
are missing. So let's stop special casing their inclusion.
  • Loading branch information...
commit bd563f0f571e7c76b40e8c8d7a0e1f34dcfeb810 1 parent 74bc63b
Claude Paroz authored July 09, 2013
30  django/contrib/gis/tests/__init__.py
... ...
@@ -1,30 +0,0 @@
1  
-def geo_apps():
2  
-    """
3  
-    Returns a list of GeoDjango test applications that reside in
4  
-    `django.contrib.gis.tests` that can be used with the current
5  
-    database and the spatial libraries that are installed.
6  
-    """
7  
-    from django.db import connection
8  
-    from django.contrib.gis.geos import GEOS_PREPARE
9  
-    from django.contrib.gis.gdal import HAS_GDAL
10  
-
11  
-    apps = ['geoapp', 'relatedapp']
12  
-
13  
-    # No distance queries on MySQL.
14  
-    if not connection.ops.mysql:
15  
-        apps.append('distapp')
16  
-
17  
-    # Test geography support with PostGIS 1.5+.
18  
-    if connection.ops.postgis and connection.ops.geography:
19  
-        apps.append('geogapp')
20  
-
21  
-    # The following GeoDjango test apps depend on GDAL support.
22  
-    if HAS_GDAL:
23  
-        # Geographic admin, LayerMapping, and ogrinspect test apps
24  
-        # all require GDAL.
25  
-        apps.extend(['geoadmin', 'layermap', 'inspectapp'])
26  
-
27  
-        # 3D apps use LayerMapping, which uses GDAL and require GEOS 3.1+.
28  
-        if connection.ops.postgis and GEOS_PREPARE:
29  
-            apps.append('geo3d')
30  
-    return [('django.contrib.gis.tests', app) for app in apps]
15  tests/runtests.py
@@ -12,16 +12,19 @@
12 12
 from django.utils import six
13 13
 
14 14
 CONTRIB_MODULE_PATH = 'django.contrib'
  15
+CONTRIB_GIS_TESTS_PATH = 'django.contrib.gis.tests'
15 16
 
16 17
 TEST_TEMPLATE_DIR = 'templates'
17 18
 
18 19
 RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
19 20
 CONTRIB_DIR = os.path.dirname(upath(contrib.__file__))
  21
+CONTRIB_GIS_TESTS_DIR = os.path.join(CONTRIB_DIR, 'gis', 'tests')
20 22
 
21 23
 TEMP_DIR = tempfile.mkdtemp(prefix='django_')
22 24
 os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
23 25
 
24 26
 SUBDIRS_TO_SKIP = [
  27
+    'data',
25 28
     'templates',
26 29
     'test_discovery_sample',
27 30
     'test_discovery_sample2',
@@ -52,7 +55,8 @@ def get_test_modules():
52 55
     modules = []
53 56
     for modpath, dirpath in (
54 57
         (None, RUNTESTS_DIR),
55  
-        (CONTRIB_MODULE_PATH, CONTRIB_DIR)):
  58
+        (CONTRIB_MODULE_PATH, CONTRIB_DIR),
  59
+        (CONTRIB_GIS_TESTS_PATH, CONTRIB_GIS_TESTS_DIR)):
56 60
         for f in os.listdir(dirpath):
57 61
             if ('.' in f or
58 62
                 # Python 3 byte code dirs (PEP 3147)
@@ -64,6 +68,7 @@ def get_test_modules():
64 68
             modules.append((modpath, f))
65 69
     return modules
66 70
 
  71
+
67 72
 def get_installed():
68 73
     from django.db.models.loading import get_apps
69 74
     return [app.__name__.rsplit('.', 1)[0] for app in get_apps()]
@@ -125,14 +130,6 @@ def no_available_apps(self):
125 130
             bits = bits[:1]
126 131
         test_labels_set.add('.'.join(bits))
127 132
 
128  
-    # If GeoDjango, then we'll want to add in the test applications
129  
-    # that are a part of its test suite.
130  
-    from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
131  
-    if HAS_SPATIAL_DB:
132  
-        from django.contrib.gis.tests import geo_apps
133  
-        test_modules.extend(geo_apps())
134  
-        settings.INSTALLED_APPS.extend(['django.contrib.gis', 'django.contrib.sitemaps'])
135  
-
136 133
     for modpath, module_name in test_modules:
137 134
         if modpath:
138 135
             module_label = '.'.join([modpath, module_name])

0 notes on commit bd563f0

Please sign in to comment.
Something went wrong with that request. Please try again.