diff -r 9221ae790640 django/core/management/commands/test.py
a
|
b
|
|
14 | 14 | |
15 | 15 | def handle(self, *test_labels, **options): |
16 | 16 | from django.conf import settings |
| 17 | from django.test.utils import get_runner |
17 | 18 | |
18 | 19 | verbosity = int(options.get('verbosity', 1)) |
19 | 20 | interactive = options.get('interactive', True) |
20 | | |
21 | | test_path = settings.TEST_RUNNER.split('.') |
22 | | # Allow for Python 2.5 relative paths |
23 | | if len(test_path) > 1: |
24 | | test_module_name = '.'.join(test_path[:-1]) |
25 | | else: |
26 | | test_module_name = '.' |
27 | | test_module = __import__(test_module_name, {}, {}, test_path[-1]) |
28 | | test_runner = getattr(test_module, test_path[-1]) |
| 21 | test_runner = get_runner(settings) |
29 | 22 | |
30 | 23 | failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive) |
31 | 24 | if failures: |
diff -r 9221ae790640 django/test/utils.py
a
|
b
|
|
65 | 65 | |
66 | 66 | del mail.outbox |
67 | 67 | |
| 68 | |
| 69 | def get_runner(settings): |
| 70 | test_path = settings.TEST_RUNNER.split('.') |
| 71 | # Allow for Python 2.5 relative paths |
| 72 | if len(test_path) > 1: |
| 73 | test_module_name = '.'.join(test_path[:-1]) |
| 74 | else: |
| 75 | test_module_name = '.' |
| 76 | test_module = __import__(test_module_name, {}, {}, test_path[-1]) |
| 77 | test_runner = getattr(test_module, test_path[-1]) |
| 78 | return test_runner |
diff -r 9221ae790640 tests/runtests.py
a
|
b
|
|
149 | 149 | pass |
150 | 150 | |
151 | 151 | # Run the test suite, including the extra validation tests. |
152 | | from django.test.simple import run_tests |
153 | | failures = run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) |
154 | | if failures: |
| 152 | from django.test.utils import get_runner |
| 153 | if not hasattr(settings, 'TEST_RUNNER'): |
| 154 | settings.TEST_RUNNER = 'django.test.simple.run_tests' |
| 155 | test_runner = get_runner(settings) |
| 156 | |
| 157 | failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) |
| 158 | if failures: |
155 | 159 | sys.exit(failures) |
156 | 160 | |
157 | 161 | # Restore the old settings. |