Seems like pre-commit runs pytest tests twice. How to reproduce:
Install pytest, pytest-cov, pre-commit
Add
.pre-commit-config.yaml
:repos: - repo: local hooks: - id: unit_test name: Run unit pytest language: python language_version: python3 entry: pytest tests/unit --cov=src/ types: [ python ] fail_fast: true stages: [commit] - id: integr_tests name: Run integration pytest language: python language_version: python3 entry: pytest tests/integration --cov=src/ types: [ python ] fail_fast: true stages: [push]
Install pre-commit:
pre-commit install --hook-type pre-commit --hooktype pre-push
Add tests to
tests/unit
folder. My structure enter image description heretest_config_source.py
contains two dummy tests to fail: enter image description hereRunning pre-commit manually
pre-commit
leads to doubled failed tests: enter image description hereRunning same command separately from pre-commit
pytest tests/unit --cov=src/
is fine: enter image description here
What am I doing wrong?