pytest-cov: --cov and xdist missing coverage
Running pytest-cov with xdist (py.test -n auto --cov --cov-report=html
) shows a warning at the end of the test run (Coverage.py warning: No data was collected
) and reports 26431/73593 covered statements versus running without xdist (py.test --cov --cov-report=html
) which reports 36879/73593 covered statements.
Versions:
coverage==4.2 pytest-cov==2.3.1 pytest==2.9.2 pytest-xdist==1.15.0
.coveragerc
[run]
source = dir1,dir2,dir3,dir4
branch = True
parallel = True
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain if non-runnable code isn't run
if __name__ == .__main__.:
# Don't complain about uncovered code in tests that were supposed to fail
@pytest.mark.xfail
# Always show line numbers of uncovered statements
show_missing = True
I’m going to work on a reproducible sample, but I’m hoping there’s some obvious config error here.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 2
- Comments: 31 (13 by maintainers)
Commits related to this issue
- This isn't working, and there isn't anything helpful in the github issue https://github.com/pytest-dev/pytest-cov/issues/129 — committed to william-richard/chili-pepper by william-richard 5 years ago
I ran into this issue when I decided to introduce parallelization to our test-suite. @kmuehlbauer 's fix totally works. This issue should be closed with that remark:
I just came across this via github search. In my case I had to export
COVERAGE_PROCESS_START=/path/to/.coveragerc
and using the folowing lines to my.coveragerc
:Then
xdist
worked correctly together withcov
.@ionelmc sorry for the long delay. I believe I found out what was going wrong.
Today we tested building the project with the latest release 2.7.1 (no
pytest-xdist
used nor installed) and the issue remained: sometimes the build failed with the messageNo data to report
though there were coverage data printed to the terminal.We then added
pytest-xdist
and used the workaround proposed by @kmuehlbauer. It worked like a charm.Our CI system was running integration tests and unit tests at the same time and I believe that this parallel execution was messing up things for
pytest-cov
.pytest-xdist
with the mentioned configurations may have guardedpytest-cov
from race conditions.Oooof … I would need help with small reproducers on the latest pytest-cov release. Pretty sure people are having different problems here.
@thedrow not sure what you’re asking. Besides having a different project layout there’s aliasing configuration (http://coverage.readthedocs.io/en/latest/config.html#paths). The issue of tardy coverage start I will fix sometime this month I hope.