coverage.py: exclude files
You can omit modules with the --omit flag. It takes a comma-separated list of path prefixes. So for example:
coverage run my_program.pycoverage report --omit=path/to/3rdparty
Omitting some files worked for me using coverage API.Well it is the same kind what Ned suggested.
Here it is how I did it:
cov = coverage.coverage(omit='/usr/lib/python2.6/site-packages/*')
In addition to the options in the other answers, you can also configure the ignored files via setup.cfg
:
[coverage:run]omit = some/directory/* debug_*.py
See the documentation for details.