Author: mtredinnick
Date: 2009-02-27 22:46:38 -0600 (Fri, 27 Feb 2009)
New Revision: 9918

Modified:
   django/trunk/django/core/management/commands/test.py
   django/trunk/django/test/utils.py
   django/trunk/tests/runtests.py
Log:
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.

Modified: django/trunk/django/core/management/commands/test.py
===================================================================
--- django/trunk/django/core/management/commands/test.py        2009-02-28 
03:02:52 UTC (rev 9917)
+++ django/trunk/django/core/management/commands/test.py        2009-02-28 
04:46:38 UTC (rev 9918)
@@ -14,19 +14,12 @@
 
     def handle(self, *test_labels, **options):
         from django.conf import settings
+        from django.test.utils import get_runner
 
         verbosity = int(options.get('verbosity', 1))
         interactive = options.get('interactive', True)
+        test_runner = get_runner(settings)
 
-        test_path = settings.TEST_RUNNER.split('.')
-        # Allow for Python 2.5 relative paths
-        if len(test_path) > 1:
-            test_module_name = '.'.join(test_path[:-1])
-        else:
-            test_module_name = '.'
-        test_module = __import__(test_module_name, {}, {}, test_path[-1])
-        test_runner = getattr(test_module, test_path[-1])
-
         failures = test_runner(test_labels, verbosity=verbosity, 
interactive=interactive)
         if failures:
             sys.exit(failures)

Modified: django/trunk/django/test/utils.py
===================================================================
--- django/trunk/django/test/utils.py   2009-02-28 03:02:52 UTC (rev 9917)
+++ django/trunk/django/test/utils.py   2009-02-28 04:46:38 UTC (rev 9918)
@@ -65,3 +65,14 @@
 
     del mail.outbox
 
+
+def get_runner(settings):
+    test_path = settings.TEST_RUNNER.split('.')
+    # Allow for Python 2.5 relative paths
+    if len(test_path) > 1:
+        test_module_name = '.'.join(test_path[:-1])
+    else:
+        test_module_name = '.'
+    test_module = __import__(test_module_name, {}, {}, test_path[-1])
+    test_runner = getattr(test_module, test_path[-1])
+    return test_runner

Modified: django/trunk/tests/runtests.py
===================================================================
--- django/trunk/tests/runtests.py      2009-02-28 03:02:52 UTC (rev 9917)
+++ django/trunk/tests/runtests.py      2009-02-28 04:46:38 UTC (rev 9918)
@@ -149,8 +149,12 @@
                 pass
 
     # Run the test suite, including the extra validation tests.
-    from django.test.simple import run_tests
-    failures = run_tests(test_labels, verbosity=verbosity, 
interactive=interactive, extra_tests=extra_tests)
+    from django.test.utils import get_runner
+    if not hasattr(settings, 'TEST_RUNNER'):
+        settings.TEST_RUNNER = 'django.test.simple.run_tests'
+    test_runner = get_runner(settings)
+
+    failures = test_runner(test_labels, verbosity=verbosity, 
interactive=interactive, extra_tests=extra_tests)
     if failures:
         sys.exit(failures)
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to