Code

Ticket #12574: 12574.diff

File 12574.diff, 1.7 KB (added by ramiro, 4 years ago)

Same patch plus moving calculation of the set of test outside of a loop

Line 
1diff -r 0b171fe8b1bc tests/runtests.py
2--- a/tests/runtests.py Mon Jan 18 12:11:01 2010 -0300
3+++ b/tests/runtests.py Mon Jan 18 19:22:09 2010 -0300
4@@ -123,22 +123,19 @@
5     get_apps()
6 
7     # Load all the test model apps.
8+    test_labels_set = set([label.split('.')[0] for label in test_labels])
9     for model_dir, model_name in get_test_models():
10         model_label = '.'.join([model_dir, model_name])
11-        try:
12-            # if the model was named on the command line, or
13-            # no models were named (i.e., run all), import
14-            # this model and add it to the list to test.
15-            if not test_labels or model_name in set([label.split('.')[0] for label in test_labels]):
16-                if verbosity >= 1:
17-                    print "Importing model %s" % model_name
18-                mod = load_app(model_label)
19-                if mod:
20-                    if model_label not in settings.INSTALLED_APPS:
21-                        settings.INSTALLED_APPS.append(model_label)
22-        except Exception, e:
23-            sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
24-            continue
25+        # if the model was named on the command line, or
26+        # no models were named (i.e., run all), import
27+        # this model and add it to the list to test.
28+        if not test_labels or model_name in test_labels_set:
29+            if verbosity >= 1:
30+                print "Importing model %s" % model_name
31+            mod = load_app(model_label)
32+            if mod:
33+                if model_label not in settings.INSTALLED_APPS:
34+                    settings.INSTALLED_APPS.append(model_label)
35 
36     # Add tests for invalid models.
37     extra_tests = []