Ticket #10165: use_testrunner_setting_on_runtests.diff

File use_testrunner_setting_on_runtests.diff, 2.4 KB (added by Leo Soto M., 16 years ago)
  • django/core/management/commands/test.py

    diff -r 9221ae790640 django/core/management/commands/test.py
    a b  
    1414
    1515    def handle(self, *test_labels, **options):
    1616        from django.conf import settings
     17        from django.test.utils import get_runner
    1718
    1819        verbosity = int(options.get('verbosity', 1))
    1920        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)
    2922
    3023        failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
    3124        if failures:
  • django/test/utils.py

    diff -r 9221ae790640 django/test/utils.py
    a b  
    6565
    6666    del mail.outbox
    6767
     68
     69def 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
  • tests/runtests.py

    diff -r 9221ae790640 tests/runtests.py
    a b  
    149149                pass
    150150
    151151    # 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:
    155159        sys.exit(failures)
    156160
    157161    # Restore the old settings.
Back to Top