python-3.xcoverage.pycoveralls

Exclude imports from coverage in Python


At the moment, I have 32% coverage of my library when testing my code using coverage, due to coverage, measuring coverage of e.g. numpy, scipy, and other imported Python libraries. The command I am using is

coverage run -m pytest -v tests/

Is there a way to exclude running test coverage for imported packages?

Thank you for your help.


Solution

  • Found the solution through the --source option in coverage:

    coverage run --source ./ -m pytest -v tests/
    

    where ./ is the current and only directory I want to include in the report.