py.test
+ gevent
如何得到准确的测试覆盖率报告?
我已经尝试过显而易见的事情,使用 py.test
的 pytest-cov
插件,但它 generates inaccurate reports when gevent is in use .
最佳答案
gevent coverage issue最近在 coveragepy
中得到修复。
但是,pytest-cov
无法运行 coverage>=4
。
一个可能的修复方法是在不使用 pytest-cov
插件的情况下,使用较新版本的 coverage.py
运行 py.test
。
首先,安装coverage >= 4
并卸载pytest-cov
插件:
pip install --pre --upgrade coverage
pip uninstall pytest-cov
将以下设置添加到 .coveragerc
:
[run]
concurrency = gevent
然后运行:
coverage run -m py.test
(而不是常规的 py.test
运行)
关于python - 使用 py.test + gevent 确定测试覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22890779/