Configuration
Django settings
Update your django settings.py
to use the anfema_django_testutils
test runner:
# settings.py
INSTALLED_APPS = [
...
"mathfilters",
"anfema_django_testutils",
]
...
TEST_RUNNER = "anfema_django_testutils.runner.TestRunner"
Options
The anfema_django_testutils
provides some options that can be set in your django settings.py
:
- COVERAGE_REPORT_ENABLED
If set to
True
(default), a coverage report will be generated.
- HTML_RESULTS_ENABLED
If set to
True
(default), test results will be stored within an HTML report.
- TEST_REPORT_DIR
A string which defines the path to where the test report will be stored.
Default is"test-report"
.
- TEST_REPORT_HTML_TEMPLATE
A string which defines the HTML template to be used to generate the test report.
Default is"test-results-template.html"
.
- TEST_REPORT_CSS
A string which defines the CSS file to be used by the test report generator.
Default is"test-results.css"
.
- TEST_REPORT_TITLE
A string which defines the test-report`s title.
Default is"Test Results"
.
Coverage settings
The coverage options can be specified in the projects pyproject.toml
file,
for instance:
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]
skip_empty = true
omit = [
"*/tests/*",
"*/tests.py",
]
See the coverage documentation for more information.
Running tests
Using the anfema_django_testutils
app extends
$ python manage.py test
by following parameters:
--snapshot-update Update the snapshots automatically.
--html, --no-html Enables respectively disables html results instead of
using the HTML_RESULTS_ENABLED setting. (default:
True)
--coverage, --no-coverage
Enables respectively disables code coverage instead of
using the COVERAGE_REPORT_ENABLED setting. (default:
True)
--report-dir DIR Defines the directory where to store the report
artifacts. If this isn't provided, the TEST_REPORT_DIR
setting will be used.
--report-title TITLE A string which defines the test-report`s title. If this
isn't provided, the TEST_REPORT_TITLE setting will be used.