From 9b9cea04b98b66a68b7588cc4c34401f5f7d7c12 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Thu, 3 Jun 2021 22:09:33 -0700 Subject: [PATCH] Refs #32668 -- Added gis_enabled argument to get_test_modules(). --- tests/runtests.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/runtests.py b/tests/runtests.py index eef7afa7c1..16942e249b 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -110,7 +110,7 @@ CONTRIB_TESTS_TO_APPS = { } -def get_test_modules(): +def get_test_modules(gis_enabled): """ Scan the tests directory and yield the names of all test modules. @@ -118,7 +118,7 @@ def get_test_modules(): the case of GIS tests, two dotted parts like "gis_tests.gdal_tests". """ discovery_dirs = [''] - if connection.features.gis_enabled: + if gis_enabled: # GIS tests are in nested apps discovery_dirs.append('gis_tests') else: @@ -216,7 +216,8 @@ def setup(verbosity, start_at, start_after, test_labels=None): # 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: + gis_enabled = connection.features.gis_enabled + if 'gis_tests' in test_labels_set and not gis_enabled: print('Aborting: A GIS database backend is required to run gis_tests.') sys.exit(1) @@ -226,7 +227,7 @@ def setup(verbosity, start_at, start_after, test_labels=None): start_label = start_at or start_after installed_app_names = set(get_installed()) - for test_module in get_test_modules(): + for test_module in get_test_modules(gis_enabled): if start_label: if not _module_match_label(test_module, start_label): continue