diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4635f3..842f0a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,23 +86,19 @@ repos: stages: ["pre-push"] id: pytest name: Run unit tests - entry: uv run pytest --quiet --cov-report=xml + entry: uv run coverage run -m pytest --quiet - <<: *tests-config - id: test-coverage # https://youtu.be/70T6OxKwxm0 + id: coverage-xml + name: Write coverage XML report + entry: uv run coverage xml --quiet + - <<: *tests-config + id: test-coverage name: Tests have 100% run coverage - entry: > - uv run coverage report - --no-skip-covered - --include 'tests/*' - --fail-under 100 + entry: uv run coverage report --no-skip-covered --include 'tests/*' --fail-under 100 - <<: *tests-config id: coverage-badge name: Generate coverage badge - entry: > - genbadge coverage - --input-file 'coverage.xml' - --output-file coverage.svg - --silent + entry: genbadge coverage --input-file 'coverage.xml' --output-file coverage.svg --silent # https://github.com/smarie/python-genbadge/releases additional_dependencies: ["genbadge[coverage]==1.1.3"] language: python diff --git a/pyproject.toml b/pyproject.toml index b691f80..b9b56b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,9 +19,9 @@ dev = [ "pre-commit>=4.6.0", ] test = [ + "coverage>=7.13.5", "covdefaults>=2.3.0", "pytest>=9.0.3", - "pytest-cov>=7.0.0", ] @@ -42,7 +42,11 @@ upgrade.shell = """ uv sync --refresh --upgrade uv run pre-commit autoupdate """ -test = "uv run pytest -vvv" +test.shell = """ + uv run coverage run -m pytest -vvv + uv run coverage report --no-skip-covered + uv run coverage xml --quiet +""" [tool.poe.tasks.lint] control.expr = "sys.platform" @@ -66,14 +70,11 @@ shell = """ [tool.pytest.ini_options] -addopts = "--cov" testpaths = ["tests"] [tool.coverage] -run.branch = true run.plugins = ["covdefaults"] # https://youtu.be/70T6OxKwxm0 report.fail_under = 80 -report.show_missing = true report.exclude_lines = [ "@pytest.mark.skip", "@pytest.mark.xfail",