Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10165 -- Use settings.TEST_RUNNER in runtests.py

This permits running Django's core tests under an alternative test runner. Most
likely useful to non-CPython implementations, rather than much else (since
Django's core tests might assume things about the test runner).

Patch from Leo Soto.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9918 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit beb20057a30a96b74dfc309c2add47148103ba63 1 parent 415ffa8
Malcolm Tredinnick authored
11  django/core/management/commands/test.py
@@ -14,18 +14,11 @@ class Command(BaseCommand):
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:
11  django/test/utils.py
@@ -65,3 +65,14 @@ def teardown_test_environment():
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
8  tests/runtests.py
@@ -149,8 +149,12 @@ def django_tests(verbosity, interactive, test_labels):
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)
  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)
154 158
     if failures:
155 159
         sys.exit(failures)
156 160
 

0 notes on commit beb2005

Please sign in to comment.
Something went wrong with that request. Please try again.