James Hiew James Hiew -3 years ago 221
Python Question

Pycharm/IntelliJ shows 0% coverage for pytest even though coverage was generated

I have a Python project and a

task, set up to run
from the project's working directory.

enter image description here

Run 'tests' with coverage
from the
menu successfully runs the tests, and the console results shows that coverage was measured - e.g. 53% cover for

enter image description here

The automatically applied coverage (as on the right) is 0% for all files, I'm not sure why. I'm using IntelliJ 2017.2.2 EAP.

NB: there is a related five year old question here, but the top rated solution there doesn't apply. There is no error message in the results console in this case.

Answer Source

I think the problem lies in you use pytest-cov, so Pycharm cannot parse the result which is shown in text like 53% generated by pytest-cov;

So Changes option in pytest.ini to addopts = -s -v when you want to use Pycharm built in coverage tools.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download