Skip to content

Instantly share code, notes, and snippets.

@streeter streeter/runner.py forked from carljm/runner.py
Created Dec 9, 2011

Embed
What would you like to do?
Unittest2 test discovery and real dotted-path named test selection for Django
from django.conf import settings
from django.test.simple import DjangoTestSuiteRunner, reorder_suite
from django.utils.unittest import TestCase
from django.utils.unittest.loader import defaultTestLoader
class DiscoveryDjangoTestSuiteRunner(DjangoTestSuiteRunner):
def build_suite(self, test_labels, extra_tests=None, **kwargs):
if test_labels:
return super(DiscoveryDjangoTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs)
else:
suite = defaultTestLoader.discover(settings.TEST_DISCOVERY_ROOT)
if extra_tests:
for test in extra_tests:
suite.addTest(test)
return reorder_suite(suite, (TestCase,))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.