-
-
Save streeter/1453891 to your computer and use it in GitHub Desktop.
Unittest2 test discovery and real dotted-path named test selection for Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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