David.B
David.B

Reputation: 380

How do I omit .virtualenv packages when testing Django project with Coverage.py

I have a Django project which I want to test with Coverage.py. I want to exclude the files in .virtualenvs. I am using pipenv and the editor is VS Code. Coverage version is 5.5

I followed the documentation instructions to create a .coveragec file in the root directory of the project. I then ran the test but Coverage does not omit the packages in .virtualenvs.

.coveragec

[run]
source = .
omit = *.virtualenvs/*,*tests*,*apps.py*,*manage.py*,*__init__.py*,*migrations*,*asgi*,*wsgi*,*admin.py*,*urls.py*

[report]
omit = *.virtualenvs/*,*tests*,*apps.py*,*manage.py*,*__init__.py*,*migrations*,*asgi*,*wsgi*,*admin.py*,*urls.py*

When this approach did not work, I then resorted to using the Command line approach. This did not also work.

cmd commands

coverage run --omit=*./virtualenvs/*,*tests*,*apps.py*,*manage.py*,*__init__.py*,*migrations*,*asgi*,*wsgi*,*admin.py*,*urls.py* manage.py test -v 2

coverage html --omit=*./virtualenvs/*,*tests*,*apps.py*,*manage.py*,*__init__.py*,*migrations*,*asgi*,*wsgi*,*admin.py*,*urls.py*

I have also used .venv instead of .virtualenvs but it still does not work. What can I do?

Upvotes: 0

Views: 242

Answers (1)

David.B
David.B

Reputation: 380

Just as @BrianD said, I solved it by renaming the file .coveragec to .coveragerc

Upvotes: 1

Related Questions