I've seen a couple of articles on the subject, but none seem to work for me.
The case
A Python package with tests based on unittest
, pytest
as test runner and plugins like pytest-cov
to support the coverage
. All works fine locally, all tests are executed and pass, coverage is calculated for all tests, including CLI tests using subprocess.check_output
.
The issue
Somehow, on Travis side, coverage is not calculated for the CLI tests. No matter what I do, no matter where and how many times I do include coverage.pth
or sitecustomize.py
(read more about it here), coverage for CLI is not included.
The obvious question
What am I doing wrong?
As a recap of what was done to solve it (for the folks that may need the answer) the issue was on my configuration of tox
to blame.
Before (did not work well, although tests passed)
[testenv]
# Some other config above this line
commands =
pytest
After (where I got it really to the 100% covered)
[testenv]
# Some other config above this line
commands =
coverage erase
pip install -e .
pytest
The pip install -e .
is obviously the key here.