A pre-commit hook to ensure you have adequate test coverage for your new or modified Python code.
Under the hood this uses:
- pytest (as the test runner)
- pytest-cov (to generate a coverage report)
- diff-cover (compares coverage report
with
git diff
)
- repo: https://github.com/TheDataShed/pre-commit-diff-cover
rev: v0.0.1
hooks:
- id: diff-cover
There are a few different arguments this hook will accept.
hooks:
- id: diff-cover
args: [--quiet, --quick, --fail-under=100]
As the name suggests, reduces the output from the underlying tooling.
Note: output is only shown if this pre-commit fails
Runs pytest
with a number of arguments to speed up the execution e.g.
--last-failed-no-failures=none
which skips unchanged tests that passed last run.
Defaults to 100
%
Fail the pre-commit check if the coverage percentage is below the specified threshold.