在pycharm / pydev中调试pytest post mortem异常 [英] Debugging pytest post mortem exceptions in pycharm/pydev
问题描述
我想使用PyCharm内置的Pytest运行器和调试器,而不需要预先配置断点。
问题是我的测试中的异常被捕获通过Pytest,PyCharm的post验证调试器无法处理异常。
我知道使用断点工作,但我不想运行我的测试两次。
在Unittest中找到一种方法,我想知道Pytest中是否存在类似的东西。
您是否使用 pytest-pycharm 插件?看起来像对我有用创建virtualenv, pip install pytest pytest-pycharm
,在PyCharm中使用此virtualenv 编辑配置 - > Python解释器
然后运行调试...
示例:
import pytest
def test_me():
assert无
如果__name__ =='__main__':
pytest.main (args = [__ file__])
PyCharm调试器停止在 设置 I would like to use the built in Pytest runner of PyCharm together with the debugger without pre-configuring breakpoints. The problem is that exceptions in my test are caught by Pytest so PyCharm's post mortem debugger cannot handle the exception. I know using a breakpoint works but I would prefer not to run my test twice. Found a way to do this in Unittest, I would like to know if something like this exists in Pytest. Is there a way to catch unittest exceptions with PyCharm? Are you using pytest-pycharm plugin? Looks like it works for me. Create virtualenv, PyCharm debugger stops at Set 这篇关于在pycharm / pydev中调试pytest post mortem异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!断言无
(< class'_pytest.assertion.reinterpret.AssertionError'>,AssertionError(u'assert None',),None)
/ p>
编辑
首选项>工具> Python集成工具>默认测试运行器
到 py.test 。然后运行>在test_me.py'中调试'py.test'
pip install pytest pytest-pycharm
, use this virtualenv at PyCharm Edit configuration -> Python Interpreter
and then run with Debug ...
Example:import pytest
def test_me():
assert None
if __name__ == '__main__':
pytest.main(args=[__file__])
assert None
point, with (<class '_pytest.assertion.reinterpret.AssertionError'>, AssertionError(u'assert None',), None)
EDIT
Preferences > Tools > Python Integration Tools > Default test runner
to py.test. Then Run > Debug 'py.test in test_me.py'