Skip to content

pytest

pytest suites: test lint rules, and passing tests before every push. Level all adds a coverage minimum. It requires python. Guide: Tests.

A scope has filenames conftest.py or pytest.ini, or a dependency on pytest.

Runs pytest with coverage, and fails on a failed test or when the covered lines fall under their minimum.

Runs at the push stage, once per scope, and loads your code and needs the Python environment of the project.

A coverage minimum keeps new code from arriving untested.

Fix each failed test, and add tests for the code that the report marks uncovered. Lower coverage.min_line_percent only with a reason.

pytest-cov reports FAIL Required test coverage of 90% not reached. Total coverage: 85%. Add a Python test for the uncovered behavior.

gspot ignore pytest/tests --paths "<path>" --reason "<why>"

To silence one place, write a comment such as:

if TYPE_CHECKING: # pragma: no cover # reason: imports for type checkers only
Setting What it sets
coverage.min_line_percent The minimum percentage of source lines covered by tests.
Tool Version
pytest 7.0.0 or later, install it yourself
pytest-cov Any, install it yourself

.gspot/configurations/pytest/coveragerc