[Answered ]-Run every TestCase inside a module

1๐Ÿ‘

โœ…

I ended up writing down my own TestSuiteRunner, like @sneawo said.

After Django-style fails, try importing as usual python-style.

One line to fix:

suite.addTest(build_test(label))

into

try:
    suite.addTest(django.test.simple.build_test(label))
except ValueError:
    # change to python-style package name
    head, tail = label.split('.', 1)
    full_label = '.'.join([head, django.test.simple.TEST_MODULE, tail])
    # load tests
    tests = unittest.defaultTestLoader.loadTestsFromName(full_label)
    suite.addTests(tests)

and set TEST_RUNNER in settings.py:

TEST_RUNNER='myapp.tests.module_test_suite_runner.ModuleTestSuiteRunner'
๐Ÿ‘คJang-hwan Kim

1๐Ÿ‘

I think to achieve this you need to subclass your own TestRunner from DjangoTestSuiteRunner and override build_suite method.

๐Ÿ‘คsneawo

Leave a comment