问题描述
启用覆盖时如何在PyCharm中调试py.test?
使用-cov = project --cov启用覆盖-report = term-missing
,删除该行并击中断点。
版本:pycharm 5.0.3,pytest == 2.8.5, pytest-cache == 1.0,pytest-cov == 2.2.0,pytest-pep8 == 1.0.6,pytest-xdist == 1.13.1,python-coveralls == 2.6.0。
(感谢乔恩对进一步诊断问题的建议)
现在有一个
额外提示:您可能还希望在其中添加 -s
标志,以便py.test不会吞噬输出。有关详细信息,请参见。
如果收到无法识别的参数错误,则可能需要安装 pytest-cov
,例如通过 pip安装pytest-cov
。
How do I debug py.test in PyCharm when coverage is enabled?
Coverage is enabled using --cov=project --cov-report=term-missing
, removing this and breakpoints are hit.
Versions: pycharm 5.0.3, pytest==2.8.5, pytest-cache==1.0, pytest-cov==2.2.0, pytest-pep8==1.0.6, pytest-xdist==1.13.1, python-coveralls==2.6.0.
(thanks for jon's advice on further diagnosing the issue)
There is now a flag in py.test to disable coverage which you can activate when running tests from PyCharm.
The flag to use is --no-cov
. If you want this to apply to all your test runs you can add this to the default pytest configuration as below:
Extra tip: You probably also want a -s
flag in there so output isn't swallowed by py.test. See https://stackoverflow.com/a/17810324/238166 for details.
In case you receive an "unrecognized argument" error, you may need to install pytest-cov
, e.g. by pip install pytest-cov
.
这篇关于启用覆盖率后如何在PyCharm中调试py.test的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!