Search code examples
python-2.7virtualenvpytesttest-coverage

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


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 ?


Solution

  • You should add your module's name to the --cov command line option, for example form pytest-cov documentation:

    py.test --cov=myproj tests/
    

    This restrict the coverage to the module myproj and all its sub-modules.