# Testing

The django backend is tested using Pytest. Pytest plugins, pytest, pytest-cov, pytest-django amongst others are also used.

# Config

PyTest: pytest-ci.ini or pytest.ini
coverage: .coveragerc

# Coverage

Coverage is a measure of how much of our codebase is "covered" by tests. A coverage report is generated by pytest using pytest-cov. The main configuration for this is in pytest-ci.iniand file ommisions are configured in .coveragerc




 
 
 
 
 








[pytest]
python_files = test*.py tests/*.py
norecursedirs = .tox node_modules deployment .git .data
addopts =
    --cov-report=term
    --cov-report=xml
    --cov=.
    --junitxml=report.xml
env =
    DJANGO_SETTINGS_MODULE=app.settings
    DATABASE_URL=postgresql://postgres:unsafe@postgres:5432/postgres
    DEBUG=True
    SECRET_KEY=notsecretatall
    EMAIL_URL=dummyurl

TIP

--cov-fail-under is set in gitlab-ci.yml to allow coverage to fail if it drops below MIN_COVERAGE_BACKEND which is set in the project variables

pytest --cov-fail-under=$MIN_COVERAGE_BACKEND -c pytest-ci.ini
Last Updated: 3/30/2022, 11:59:30 AM