I am new to coverage and ran into a strange problem. My coverage is taking my virtual environment site packages into account. Here is the output of the coverage run:
<
Thanks to tknickman I figured it out: Use either
coverage run --source test.py
or create a configuration file .coveragerc which resides in the directory you run coverage from, with the following content:
[run]
source =
This provides you do not have your virtual environment installed under the project directory. If you have the virtual environment installed under the project dir you can use
coverage run --source --omit test.py
Note that omit wants a file pattern like
~/projectdir/venv/*
instead of a path.
The corresponding .coveragerc would look like this:
[run]
source=
omit=
//*
I still think that like packages of the standard library any packages installed under site-packages should not be covered by default.