From faa5405cf96e3da4e31be587cccbd48121372567 Mon Sep 17 00:00:00 2001 From: t0kubetsu Date: Wed, 12 Aug 2026 16:25:11 +0200 Subject: [PATCH 1/2] 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 dc8fd9a..e843ec6 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=100 diff --git a/pyproject.toml b/pyproject.toml index 49b36c4..50410b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,4 +74,4 @@ select = ["E4", "E7", "E9", "F"] [tool.pytest.ini_options] pythonpath = ["."] testpaths = ["tests"] -addopts = "--cov=quantumvalidator --cov-report=term-missing --cov-fail-under=100" +addopts = "--cov=quantumvalidator --cov-report=term-missing" From 0b7ed530f593aa4e27ffe47bf1454c2e7adb5c8a Mon Sep 17 00:00:00 2001 From: t0kubetsu Date: Wed, 12 Aug 2026 16:26:41 +0200 Subject: [PATCH 2/2] docs: CLAUDE.md no longer says the gate lives in addopts The coverage threshold moved to the CI pytest step in this branch, so the 'enforced via pyproject.toml addopts' line is no longer accurate. --- CLAUDE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 60f1962..8af74aa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -70,7 +70,8 @@ Two mock targets in tests: - **CLI mocking**: patch `"quantumvalidator.assessor.assess"` and `"quantumvalidator.reporter.print_full_report"` (both are lazy imports inside `check()`) - **Reporter tests**: use `Console(file=StringIO(), no_color=True, width=200)` to capture output; pass `console=con` as a keyword argument — all reporter functions (public and private) accept `console=` - **Test class naming**: `class TestFeatureName:`, snake_case methods, AAA structure -- **Coverage target**: 100% — enforced via `pyproject.toml` addopts +- **Coverage target**: 100% — enforced by CI (`--cov-fail-under=100` on the + workflow's pytest step, not in `addopts`, so targeted runs are not gated) ## Exit Codes