无法使用 pytest 在 pycharm 中进行调试 [英] Unable to debug in pycharm with pytest

查看:93
本文介绍了无法使用 pytest 在 pycharm 中进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用 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-删除断点

运行/调试配置:py.test

推荐答案

就我的情况,我发现了问题所在:

For my situation, i found what the problem is:

如果pytest.ini中有--cov,那么pycharm中的断点将不起作用,删除所有--covpytest.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

参考资料:

如何调试py.test启用覆盖时的 PyCharm

这篇关于无法使用 pytest 在 pycharm 中进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆