简体   繁体   中英

determining test coverage with py.test + gevent

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 .

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM