Search code examples
pythonpython-2.7nosetestscoverage.py

Exclude files from coverage report


I'm trying to exclude some files from a coverage report. I'm using TravisCI and Coveralls.io for test my project.

My test code is as follows:

script:
  - cd ../
  - nosetests --with-coverage --cover-erase --cover-inclusive
  - cd tests

after_success:
  - cd ../
  - coverage report --omit '/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/*'
  - coverage combine
  - cat .coverage
  - coveralls

(I removed the unnecesary code for this question).

In this code I perform a complete test of all files and then I exclude the libraries, libraries not created by me, for the final report.

The problem is that while the screen shows me a small report, the output file is the original. I checked their content using a cat .coverage.

What could I be doing wrong?


Solution

  • Most likely, you are only interested in the files in your project. You can use the source option to focus coverage on just that tree:

    # .coveragerc
    [run]
    source = .