Using different testing frameworks
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 ...
Get Mastering Django: Core now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.