How can one get an accurate test coverage report when using py.test
+ gevent
?
I've already tried the obvious thing, using the pytest-cov
plugin for py.test
, but it generates inaccurate reports when gevent is in use.
Increase coverage by adding more tests The code coverage has increased to 78% on adding another test case. It can be increased further to 100% in a similar fashion.
The output tells us that in example. lib we have one partial branch (BrPart) which reduces the coverage in that module to 86% in this case.
The gevent coverage issue was fixed in coveragepy
recently.
However, pytest-cov
fails to run with coverage>=4
.
One possible fix, is to run py.test
with the later versions of coverage.py
without using the pytest-cov
plugin.
First, install coverage >= 4
and uninstall the pytest-cov
plugin:
pip install --pre --upgrade coverage
pip uninstall pytest-cov
Add the following setting to .coveragerc
:
[run]
concurrency = gevent
Then run with:
coverage run -m py.test
(instead of the regular py.test
run)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With