Pycharm code coverage omit directories
Hi,
I'm using PyCharm Professional Edition developing a Django application and I'd like to omit certain directories from the code coverage (e.g. *tests* and some others).
Using .coveragerc with (I know I should not omit the migrations generally):
[run]
source = .
omit = *tests*, *migrations*
I see what I want using:
coverage erase
coverage run manage.py test --keepdb
coverage report
I know that PyCharm is reading the file because when I execute the tests with Coverage from PyCharm it says:
Loading rcfile: /home/carles/git/project-application/ProjectApplication/.coveragerc
But the coverage for tests is still there. I've tried with source = source to the place, setup the working directory in the PyCharm "runner", etc. etc. it appears on the coverage output from PyCharm and also in the file (showing 100% rate for the tests).
How can I instruct PyCharm to ignore during the code coverage the tests?
Thank you very much,
Carles
Please sign in to leave a comment.
Hi,
Does the issue reproduce if you run `coverage run manage.py test --keepdb` from the terminal ?
Please copy-paste the run command from the first line of the run console.
Hi,
`coverage run manage.py test --keepdb` works fine (it's omitting the files that I expected)
Testing started at 12:46 ...
/home/carles/git/project-application/venv/bin/python3 /home/carles/bin/pycharm-2019.2.3/plugins/python/helpers/coverage_runner/run_coverage.py run --omit=\"/home/carles/bin/pycharm-2019.2.3/plugins/python/helpers*\" /home/carles/bin/pycharm-2019.2.3/plugins/python/helpers/pycharm/django_test_manage.py test --keepdb -v 3 /home/carles/git/project-application/ProjectApplication
Loading rcfile: /home/carles/git/project-application/ProjectApplication/.coveragerc
Some notes:
a) pycharm-2019.2.3 is the one that I'm using
b) I tried specifying the working directory in Pycharm
c) In .coveragerc I tried to specify full paths instead of relative file paths
Thank you very much for your attention,
Carles
Andrey answer in another channel and just to help if someone reads it here: in PyCharm settings -> Build, Execute, Deployment -> Coverage if I enable "Use bundled coverage.py" it works as expected.
Cheers,
Carles
I have the same problem even when I selected "Use bundled coverage".
I can see the *tests* directory being included in the --omit argument, so I know that my .coveragerc file is being found in my home directory, but coverage is STILL running coverage on the tests themselves (which is what I am trying to skip)
Should I file a separate bug report?
Please see
https://youtrack.jetbrains.com/issue/PY-41334
https://youtrack.jetbrains.com/issue/PY-42789
Does it help to enable/disable bundled coverage?
Andrey Resler
No. I've tried both ways, the results are the same.
I've filed a new bug report.
I've forgotten to mention the following
PyCharm 2020.1.1 (Professional Edition)
Build #PY-201.7223.92, built on April 29, 2020
Licensed to Me
Subscription is active until November 24, 2020
Runtime version: 11.0.6+8-b765.40 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1969M
Cores: 8
Non-Bundled Plugins: com.daylerees.rainglow, com.pablogsal.black, mobi.hsz.idea.gitignore, izhangzhihao.rainbow.brackets, com.leinardi.pycharm.pylint, intellij-micropython, org.nik.presentation-assistant
This was reported ~4 weeks ago here:
https://youtrack.jetbrains.com/issue/PY-42789
as well as in my bug report from July 1, 2020