Browse files

Only import gis test apps for geo-enabled DBs

  • Loading branch information...
1 parent bd563f0 commit 57f190ed3b77eb105cc86ecfabc455662410d40a @claudep claudep committed Jul 9, 2013
Showing with 10 additions and 5 deletions.
  1. +10 −5 tests/
@@ -12,13 +12,11 @@
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_')
@@ -52,11 +50,18 @@
def get_test_modules():
+ from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
modules = []
- for modpath, dirpath in (
+ discovery_paths = [
+ ]
+ discovery_paths.append(
+ ('django.contrib.gis.tests', os.path.join(CONTRIB_DIR, 'gis', 'tests'))
+ )
+ for modpath, dirpath in discovery_paths:
for f in os.listdir(dirpath):
if ('.' in f or
# Python 3 byte code dirs (PEP 3147)

6 comments on commit 57f190e

carljm commented on 57f190e Jul 9, 2013

@claudep Can you clarify the reason for this commit (since it's not linked to a ticket or any other rationale)? With the test discovery patch we made an intentional choice to treat the GIS tests less magically and include them along with everything else, using the normal test-skipping decorators in the test files themselves to skip specific tests that cannot be run with a non-spatial backend. This also makes test counts more consistent, since the not-run tests are reported as skipped rather than omitted entirely.

If this choice was causing a specific problem I'm not necessarily opposed to reversing it, but I'd like to know what the problem was.


Oh, never mind - I see the previous commit now. I guess we hadn't removed the magic for the test apps within django.contrib.gis.tests, and you're doing that now. I am still curious though why this follow-up commit was necessary.


I broke the test suite with the previous commit. The problem is that loading gis test apps with a non gis-enabled backend chokes when trying to create gis database fields. See,python=python2.7/console


Yeah, I saw that in the IRC backlog just now. I suppose the other option would be to make the model definitions in conditional on HAS_SPATIAL_DB.


Yes, that would also be an option. Just tell me if you'd prefer that option.


Eh, I don't think it's worth changing. It's effectively the same thing; either we add them to INSTALLED_APPS conditionally as you do here, or we always add them to INSTALLED_APPS and make their model definitions conditional. Not seeing a significant advantage to either approach.

Please sign in to comment.