无法使用 pytest 在 pycharm 中进行调试 [英] Unable to debug in pycharm with pytest
问题描述
我无法使用 py.test 在 PyCharm 中调试.所有测试套件在调试模式"下运行正常,但不会在断点处停止.
I cannot debug in PyCharm using py.test. All the test suite is running ok in "Debug mode" but it doesn't stop on breakpoints.
我也有 py.test 作为默认测试运行器.
I also have py.test as the default test runner.
也许这并不重要,但在我的 Django 服务器中调试工作正常.
Maybe this is not important, but debugging works correctly in my Django server.
有什么想法吗?
图片 enable_breakpoints_and_the_mode_of_pycharm_is_debug
参考文献:
pycharm-enabling-disabling-and-删除断点
推荐答案
就我的情况,我发现了问题所在:
For my situation, i found what the problem is:
如果pytest.ini
中有--cov
,那么pycharm中的断点将不起作用,删除所有--cov
在pytest.ini
中,pycharm中的断点是可以工作的.
If there is --cov
in pytest.ini
, then breakpoints in pycharm won't work, after deleting all --cov
in pytest.ini
, the breakpoints in pycharm can work.
原因:
coverage 模块和 pycharm 的调试器使用相同的跟踪 api (sys.settrace) - 它们不能一起工作." -- https://github.com/pytest-dev/pytest-cov/issues/131
"The coverage module and pycharm's debugger use the same tracing api (sys.settrace) - they don't work together. " -- https://github.com/pytest-dev/pytest-cov/issues/131
参考资料:
这篇关于无法使用 pytest 在 pycharm 中进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!