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.
This commit is contained in:
Claude Paroz 2013-07-09 15:17:26 +02:00
parent 74bc63b109
commit bd563f0f57
2 changed files with 6 additions and 39 deletions

View File

@ -1,30 +0,0 @@
def geo_apps():
"""
Returns a list of GeoDjango test applications that reside in
`django.contrib.gis.tests` that can be used with the current
database and the spatial libraries that are installed.
"""
from django.db import connection
from django.contrib.gis.geos import GEOS_PREPARE
from django.contrib.gis.gdal import HAS_GDAL
apps = ['geoapp', 'relatedapp']
# No distance queries on MySQL.
if not connection.ops.mysql:
apps.append('distapp')
# Test geography support with PostGIS 1.5+.
if connection.ops.postgis and connection.ops.geography:
apps.append('geogapp')
# The following GeoDjango test apps depend on GDAL support.
if HAS_GDAL:
# Geographic admin, LayerMapping, and ogrinspect test apps
# all require GDAL.
apps.extend(['geoadmin', 'layermap', 'inspectapp'])
# 3D apps use LayerMapping, which uses GDAL and require GEOS 3.1+.
if connection.ops.postgis and GEOS_PREPARE:
apps.append('geo3d')
return [('django.contrib.gis.tests', app) for app in apps]

View File

@ -12,16 +12,19 @@ from django.utils._os import upath
from django.utils import six
CONTRIB_MODULE_PATH = 'django.contrib'
CONTRIB_GIS_TESTS_PATH = 'django.contrib.gis.tests'
TEST_TEMPLATE_DIR = 'templates'
RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
CONTRIB_DIR = os.path.dirname(upath(contrib.__file__))
CONTRIB_GIS_TESTS_DIR = os.path.join(CONTRIB_DIR, 'gis', 'tests')
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
SUBDIRS_TO_SKIP = [
'data',
'templates',
'test_discovery_sample',
'test_discovery_sample2',
@ -52,7 +55,8 @@ def get_test_modules():
modules = []
for modpath, dirpath in (
(None, RUNTESTS_DIR),
(CONTRIB_MODULE_PATH, CONTRIB_DIR)):
(CONTRIB_MODULE_PATH, CONTRIB_DIR),
(CONTRIB_GIS_TESTS_PATH, CONTRIB_GIS_TESTS_DIR)):
for f in os.listdir(dirpath):
if ('.' in f or
# Python 3 byte code dirs (PEP 3147)
@ -64,6 +68,7 @@ def get_test_modules():
modules.append((modpath, f))
return modules
def get_installed():
from django.db.models.loading import get_apps
return [app.__name__.rsplit('.', 1)[0] for app in get_apps()]
@ -125,14 +130,6 @@ def setup(verbosity, test_labels):
bits = bits[:1]
test_labels_set.add('.'.join(bits))
# If GeoDjango, then we'll want to add in the test applications
# that are a part of its test suite.
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
if HAS_SPATIAL_DB:
from django.contrib.gis.tests import geo_apps
test_modules.extend(geo_apps())
settings.INSTALLED_APPS.extend(['django.contrib.gis', 'django.contrib.sitemaps'])
for modpath, module_name in test_modules:
if modpath:
module_label = '.'.join([modpath, module_name])