From 581ffee72cf90fdae1a681b6720bd3b3b610110c Mon Sep 17 00:00:00 2001 From: t0kubetsu Date: Wed, 12 Aug 2026 16:25:17 +0200 Subject: [PATCH] ci: move the coverage gate out of addopts into the CI step --cov-fail-under in pyproject addopts applies to every pytest invocation, not just full runs. A targeted command from CLAUDE.md such as pytest tests/test_assessor.py::TestAssess -v measures the whole package while executing one class, so it reports roughly 3% coverage and exits non-zero even though every selected test passed. That makes the documented developer workflow unusable. The gate moves to the workflow pytest step: CI still enforces the same threshold on the full suite, targeted runs behave again. Verified both directions -- the targeted command now exits 0, and the full run still reports "Required test coverage ... reached". --- .github/workflows/ci.yml | 8 +++++++- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 236e1ad..5afb934 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,4 +52,10 @@ jobs: - name: Test # Network I/O is isolated in the *_utils modules and mocked there, so # the suite needs neither a live network nor any external binary. - run: pytest --tb=short -q + # + # --cov-fail-under lives here rather than in pyproject addopts: in + # addopts it also applies to targeted runs such as + # `pytest tests/test_x.py::TestY -v`, which measure the whole package + # while executing one class and so fail the gate at ~3% coverage even + # when every selected test passes. + run: pytest --tb=short -q --cov-fail-under=80 diff --git a/pyproject.toml b/pyproject.toml index 01b50ac..f4ea3d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,4 +70,4 @@ select = ["E4", "E7", "E9", "F"] [tool.pytest.ini_options] pythonpath = ["."] testpaths = ["tests"] -addopts = "--cov=subdomainenum --cov-report=term-missing --cov-fail-under=80" +addopts = "--cov=subdomainenum --cov-report=term-missing"