question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--cov and xdist missing coverage

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

6reactions
rrlamichhanecommented, Nov 5, 2020

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:

# .coveragerc
[run]
concurrency = multiprocessing
parallel = true
3reactions
kmuehlbauercommented, Mar 25, 2019

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:

[run]
concurrency = multiprocessing
parallel = true

Then xdist worked correctly together with cov.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Distributed testing (xdist) — pytest-cov 4.0.0 documentation
Distributed testing with dist mode set to “load” will report on the combined coverage of all workers. The workers may be spread out...
Read more >
Missing test coverage for class declaration with pytest-cov
Ok, I found a reason. When pytest is invoked from test itself, all imports are done already, and, therefore, they are not counted...
Read more >
pytest-cov - Read the Docs
For distributed testing support install pytest-xdist: ... coverage of several test runs you can use the --cov-append option to append this ...
Read more >
pytest-cov - PyPI
Pytest plugin for measuring coverage. ... pip install pytest-cov. For distributed testing support install pytest-xdist: ... Name Stmts Miss Cover ...
Read more >
METADATA - Brilliant Tech
Home-page: https://github.com/pytest-dev/pytest-cov Author: Marc Schlaich ... e.g. ``--cov-report term-missing:skip-covered`` These three report options ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found