I have the following directory structure:
./
src/
tests/
unit/
integration/
I would like to use pytest to run all of the tests in both unit/ and integration/, but I would only like coverage.py to calculate coverage for the src/ directory when running the unit/ tests (not when running integration/ tests).
The command I'm using now (calculates coverage for all tests under tests/):
pytest --cov-config=setup.cfg --cov=src
with a setup.cfg file:
[tool:pytest]
testpaths = tests
[coverage:run]
branch = True
I understand that I could add the @pytest.mark.no_cover decorator to each test function in the integration tests, but I would prefer to mark the whole directory rather than to decorate a large number of functions.