summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-05-30 15:14:32 -0400
committerTim Graham <timograham@gmail.com>2017-05-30 15:14:55 -0400
commit48274c15893a6d4dd0700e24c3636cf56333c593 (patch)
tree9b2a6c595e4e41ca2bf84c7985f1ff1ec4ad3dcb
parent4e675999d530692f96745f5a54ba0376acd39e22 (diff)
[1.11.x] Fixed AppRegistryNotReady error when running gis_tests in isolation on PostGIS.
Regression in 890537253cf235091816d27a5c2fb64943c8e34a. Backport of 4a251f8bce2e65a445fb2c46c2f71f763311c0ac from master
-rwxr-xr-xtests/runtests.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index e89ac2a258..b8e98691bd 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -113,10 +113,6 @@ def setup(verbosity, test_labels, parallel):
bits = label.split('.')[:1]
test_labels_set.add('.'.join(bits))
- if 'gis_tests' in test_labels_set and not connection.features.gis_enabled:
- print('Aborting: A GIS database backend is required to run gis_tests.')
- sys.exit(1)
-
if verbosity >= 1:
msg = "Testing against Django installed in '%s'" % os.path.dirname(django.__file__)
max_parallel = default_test_processes() if parallel == 0 else parallel
@@ -193,6 +189,14 @@ def setup(verbosity, test_labels, parallel):
# Load all the ALWAYS_INSTALLED_APPS.
django.setup()
+ # It would be nice to put this validation earlier but it must come after
+ # django.setup() so that connection.features.gis_enabled can be accessed
+ # without raising AppRegistryNotReady when running gis_tests in isolation
+ # on some backends (e.g. PostGIS).
+ if 'gis_tests' in test_labels_set and not connection.features.gis_enabled:
+ print('Aborting: A GIS database backend is required to run gis_tests.')
+ sys.exit(1)
+
# Load all the test model apps.
test_modules = get_test_modules()