pytest
pytest suites: test lint rules, and passing tests before every push. Level all adds a coverage minimum. It requires python. Guide: Tests.
Selected when
Section titled “Selected when”A scope has filenames conftest.py or pytest.ini, or a dependency on pytest.
Checks
Section titled “Checks”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.
What to do
Section titled “What to do”Fix each failed test, and add tests for the code that the report marks uncovered. Lower coverage.min_line_percent only with a reason.
Example
Section titled “Example”pytest-cov reports FAIL Required test coverage of 90% not reached. Total coverage: 85%. Add a Python test for the uncovered behavior.
Turn it off
Section titled “Turn it off”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 onlySettings
Section titled “Settings”| Setting | What it sets |
|---|---|
coverage.min_line_percent |
The minimum percentage of source lines covered by tests. |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| pytest | 7.0.0 or later, install it yourself |
| pytest-cov | Any, install it yourself |
Files gspot writes
Section titled “Files gspot writes”.gspot/configurations/pytest/coveragerc