Unable to debug in pycharm with pytest

davyria picture davyria · Nov 21, 2016 · Viewed 17.1k times · Source

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.

Debug Mode

I also have py.test as the default test runner.

Maybe this is not important, but debugging works correctly in my Django server.

Any ideas?

Configuration picture of enable_breakpoints_and_the_mode_of_pycharm_is_debug

References:

pycharm-enabling-disabling-and-removing-breakpoints

Run/Debug Configuration: py.test

Answer

Simin Jie picture Simin Jie · Dec 1, 2016

For my situation, i found what the problem is:

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.

Reason:

"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

References:

How to debug py.test in PyCharm when coverage is enabled