February 2022
Intermediate to advanced
274 pages
6h 28m
English
With a couple of changes to the tox.ini file, tox can add coverage reports to its test runs. To do so, we need to add pytest-cov to the deps setting so that the pytest-cov plugin will be installed in the tox test environments. Pulling in pytest-cov will also include all of its dependencies, like coverage. We then extend the commands call to pytest to be pytest --cov=cards:
| | [testenv] |
| | deps = |
| | pytest |
| | faker |
| | pytest-cov |
| | commands = pytest --cov=cards |
When using coverage with tox, it’s also nice to set up a .coveragerc file to let coverage know which source paths should be considered identical:
| | [paths] |
| | source = |
| | src |
| | .tox/*/site-packages ... |
Read now
Unlock full access