Exclude imports from coverage in Python

1.2k Views Asked by At

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.

1

There are 1 best solutions below

0
GMc On BEST ANSWER

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.