Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to debug in pycharm with pytest

Tags:

pycharm

pytest

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

like image 897
davyria Avatar asked Nov 21 '16 11:11

davyria


People also ask

Why is my debugger not working in PyCharm?

What fixed the problem for me is enabling the "Gevent compatible" checkbox the File → Settings → Build, Execution and Deployment → Python Debugger (not "Debugger"). Show activity on this post. I was using pyCharm 2018.1.

How do I enable debug mode in PyCharm?

Just right-click any line in the editor and select the Debug <filename> command from the context menu. After the program has been suspended, use the debugger to get the information about the state of the program and how it changes during running.


1 Answers

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

like image 165
Cloud Avatar answered Oct 11 '22 16:10

Cloud