Code

Ticket #6168: runtests_bug.2.diff

File runtests_bug.2.diff, 903 bytes (added by floguy, 6 years ago)

Fixed the real problem. The tests were getting added just fine, but "test_labels" was still getting passed in along with the other apps. When the test runner attempted to import the "invalid_models" app, then everything crashed and burned. Simply removing that entry from test_labels keeps all other functionality intact while fixing the problem at hand.

Line 
1Index: tests/runtests.py
2===================================================================
3--- tests/runtests.py   (revision 7261)
4+++ tests/runtests.py   (working copy)
5@@ -118,7 +118,6 @@
6     get_apps()
7 
8     # Load all the test model apps.
9-    test_models = []
10     for model_dir, model_name in get_test_models():
11         model_label = '.'.join([model_dir, model_name])
12         try:
13@@ -142,6 +141,13 @@
14         model_label = '.'.join([model_dir, model_name])
15         if not test_labels or model_name in test_labels:
16             extra_tests.append(InvalidModelTestCase(model_label))
17+   
18+    # "invalid_models" is not an app, so we cannot pass it in with the other
19+    # test_labels
20+    try:
21+        test_labels.remove("invalid_models")
22+    except ValueError:
23+        pass
24 
25     # Run the test suite, including the extra validation tests.
26     from django.test.simple import run_tests