summaryrefslogtreecommitdiff
path: root/tests/runtests.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-09 19:20:39 -0500
committerTim Graham <timograham@gmail.com>2015-02-11 11:47:58 -0500
commit36bf6ec9eb8a3ef4e24d3a6374780603f5bbdf97 (patch)
treeaa8433e22b89b76e54d985ce601d03613d0564c3 /tests/runtests.py
parenta0553d1a7cb4f5ecca90650ef9ebad4c44cf6b43 (diff)
[1.8.x] Moved contrib.flatpages tests out of contrib.
Backport of d3a725054fa260e84c788b240fd03cbd0ccc1151 from master
Diffstat (limited to 'tests/runtests.py')
-rwxr-xr-xtests/runtests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index 796b27c2bb..3616d019e9 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -60,6 +60,14 @@ ALWAYS_MIDDLEWARE_CLASSES = (
'django.contrib.messages.middleware.MessageMiddleware',
)
+# Need to add the associated contrib app to INSTALLED_APPS in some cases to
+# avoid "RuntimeError: Model class X doesn't declare an explicit app_label
+# and either isn't in an application in INSTALLED_APPS or else was imported
+# before its application was loaded."
+CONTRIB_TESTS_TO_APPS = {
+ 'flatpages_tests': 'django.contrib.flatpages',
+}
+
def get_test_modules():
modules = []
@@ -142,6 +150,7 @@ def setup(verbosity, test_labels):
# us skip creating migrations for the test models.
'auth': 'django.contrib.auth.tests.migrations',
'contenttypes': 'django.contrib.contenttypes.tests.migrations',
+ 'flatpages_tests': 'django.contrib.flatpages.migrations',
}
if verbosity > 0:
@@ -191,6 +200,9 @@ def setup(verbosity, test_labels):
module_label == label or module_label.startswith(label + '.')
for label in test_labels_set)
+ if module_name in CONTRIB_TESTS_TO_APPS and module_found_in_labels:
+ settings.INSTALLED_APPS.append(CONTRIB_TESTS_TO_APPS[module_name])
+
if module_found_in_labels and module_label not in installed_app_names:
if verbosity >= 2:
print("Importing application %s" % module_name)