Debugging pytest post mortem exceptions in pycharm/pydev

前端 未结 1 1841
栀梦
栀梦 2020-12-31 16:14

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 a

相关标签:
1条回答
  • 2020-12-31 16:59

    Are you using pytest-pycharm plugin? Looks like it works for me. Create virtualenv, 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__])
    

    PyCharm debugger stops at assert None point, with (<class '_pytest.assertion.reinterpret.AssertionError'>, AssertionError(u'assert None',), None)

    EDIT

    Set Preferences > Tools > Python Integration Tools > Default test runner to py.test. Then Run > Debug 'py.test in test_me.py'

    0 讨论(0)
提交回复
热议问题