Clearly, unittest
is not the only Python testing framework. While Django doesn't provide explicit support for alternative frameworks, it does provide a way to invoke tests constructed for an alternative framework as if they were normal Django tests.
When you run ./manage.py test
, Django looks at the TEST_RUNNER
setting to determine what to do. By default, TEST_RUNNER
points to django.test.runner.DiscoverRunner
. This class defines the default Django testing behavior. This behavior involves:
Performing global pre-test setup.
Looking for tests in any of the following file the in current directory whose name matches the pattern
test*.py
.Creating the test databases.
Running migrate to install models and initial data into the test databases.
Running the tests that were found.
Destroying the test databases.
Performing global post-test teardown.
If you define your own test runner class and point TEST_RUNNER
at that class, Django will execute your test runner whenever you...