Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

How do I debug py.test in PyCharm when coverage is enabled?

Coverage is enabled using --cov=project --cov-report=term-missing, removing this and breakpoints are hit.

Versions: pycharm 5.0.3, pytest==2.8.5, pytest-cache==1.0, pytest-cov==2.2.0, pytest-pep8==1.0.6, pytest-xdist==1.13.1, python-coveralls==2.6.0.

(thanks for jon's advice on further diagnosing the issue)

like image 566
simonzack Avatar asked Jan 19 '16 07:01

simonzack


People also ask

How do I Debug a test in PyCharm?

Debug failed testsOpen the test file in the editor. Right-click it and select the Debug <test name>. PyCharm stops on every failed test and shows the reason for the failure. Inspect the Variables pane of the Debugger tool window to get more details about the problems.

How do I enable debugging actions 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

There is now a flag in py.test to disable coverage which you can activate when running tests from PyCharm.

The flag to use is --no-cov. If you want this to apply to all your test runs you can add this to the default pytest configuration as below: Pycharm pytest debug

Extra tip: You probably also want a -s flag in there so output isn't swallowed by py.test. See https://stackoverflow.com/a/17810324/238166 for details.

In case you receive an "unrecognized argument" error, you may need to install pytest-cov, e.g. by pip install pytest-cov.

like image 183
Inti Avatar answered Sep 19 '22 14:09

Inti