how to make py.test --cov skip virtualenv directory

David Ben Ari picture David Ben Ari · Jan 7, 2016 · Viewed 11.4k times · Source

Should I care how my tests cover the external libraries I'm using in my project ?

The py.test --cov displays how all files are covered, including ones in my virtualenv directory. How can I make the output show only the coverage of the modules I've written ?

Answer

sashk picture sashk · Jan 8, 2016

In the root of your project, create file .coveragerc containing:

[run]
omit = path_to_libs_to_omit/*

Depending on your setup, you might need to add --cov-config=path/to/.coveragerc as option to the py.test command.

There are more options you can use to configure coverage.