diff -r 7dc2faae6336 django/contrib/gis/tests/__init__.py
a
|
b
|
|
17 | 17 | return test_runner.run_tests(test_labels, extra_tests=extra_tests) |
18 | 18 | |
19 | 19 | |
20 | | def geo_apps(namespace=True): |
| 20 | def geo_apps(namespace=True, runtests=False): |
21 | 21 | """ |
22 | 22 | Returns a list of GeoDjango test applications that reside in |
23 | 23 | `django.contrib.gis.tests` that can be used with the current |
… |
… |
|
45 | 45 | |
46 | 46 | apps.append('layermap') |
47 | 47 | |
48 | | if namespace: |
| 48 | if runtests: |
| 49 | return [('django.contrib.gis.tests', app) for app in apps] |
| 50 | elif namespace: |
49 | 51 | return ['django.contrib.gis.tests.%s' % app |
50 | 52 | for app in apps] |
51 | 53 | else: |
52 | 54 | return apps |
53 | 55 | |
54 | 56 | |
55 | | def geodjango_suite(): |
| 57 | def geodjango_suite(apps=True): |
56 | 58 | """ |
57 | 59 | Returns a TestSuite consisting only of GeoDjango tests that can be run. |
58 | 60 | """ |
… |
… |
|
89 | 91 | suite.addTest(test_geoip.suite()) |
90 | 92 | |
91 | 93 | # Finally, adding the suites for each of the GeoDjango test apps. |
92 | | for app_name in geo_apps(namespace=False): |
93 | | suite.addTest(build_suite(get_app(app_name))) |
| 94 | if apps: |
| 95 | for app_name in geo_apps(namespace=False): |
| 96 | suite.addTest(build_suite(get_app(app_name))) |
94 | 97 | |
95 | 98 | return suite |
96 | 99 | |
diff -r 7dc2faae6336 tests/runtests.py
a
|
b
|
|
30 | 30 | 'django.contrib.staticfiles', |
31 | 31 | ] |
32 | 32 | |
| 33 | def geodjango(settings): |
| 34 | return settings.DATABASES['default']['ENGINE'].startswith('django.contrib.gis') |
| 35 | |
33 | 36 | def get_test_models(): |
34 | 37 | models = [] |
35 | 38 | for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR): |
… |
… |
|
124 | 127 | |
125 | 128 | # Load all the test model apps. |
126 | 129 | test_labels_set = set([label.split('.')[0] for label in test_labels]) |
127 | | for model_dir, model_name in get_test_models(): |
| 130 | test_models = get_test_models() |
| 131 | |
| 132 | # If GeoDjango, then we'll want to add in the test applications |
| 133 | # that are a part of its test suite. |
| 134 | if geodjango(settings): |
| 135 | from django.contrib.gis.tests import geo_apps |
| 136 | test_models.extend(geo_apps(runtests=True)) |
| 137 | |
| 138 | for model_dir, model_name in test_models: |
128 | 139 | model_label = '.'.join([model_dir, model_name]) |
129 | 140 | # if the model was named on the command line, or |
130 | 141 | # no models were named (i.e., run all), import |
… |
… |
|
162 | 173 | except ValueError: |
163 | 174 | pass |
164 | 175 | |
| 176 | # If GeoDjango is used, add it's tests that aren't a part of |
| 177 | # an application (e.g., GEOS, GDAL, Distance objects). |
| 178 | if geodjango(settings): |
| 179 | from django.contrib.gis.tests import geodjango_suite |
| 180 | extra_tests.append(geodjango_suite(apps=False)) |
| 181 | |
165 | 182 | # Run the test suite, including the extra validation tests. |
166 | 183 | from django.test.utils import get_runner |
167 | 184 | if not hasattr(settings, 'TEST_RUNNER'): |