Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(coverage): recommend a per-test coverage command that exists (#3676)
Yunus Ozen039517e181ac
diff --git a/README.md b/README.mdindex 13d404796..a8acf21ad 100644--- a/README.md+++ b/README.md@@ -327,7 +327,7 @@ repowise impacted-tests main..HEAD # only the tests this diff exercisesrepowise health # untested hotspots, graph-aware```-<sub>Checked against a real <code>coverage run --contexts=test</code> on this repository:+<sub>Checked against real per-test coverage on this repository:<strong>95.7% precision</strong> on what reaches a file and <strong>97.5% on the runlist</strong>. Every row is stamped <code>basis: "measured"</code> or<code>"inferred"</code>, measured wins where both can answer, and an empty answer meansdiff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.mdindex 2b54865ac..cfc677f3d 100644--- a/docs/BENCHMARKS.md+++ b/docs/BENCHMARKS.md@@ -429,8 +429,8 @@ changed. On aspnetcore, an update with no changes takes about 4 seconds.## Test intelligenceRepowise links tests to the code they exercise from the call graph, with no-coverage run needed. We checked those inferred links against a real-`coverage run --contexts=test` on this repository, over a slice with complete+coverage run needed. We checked those inferred links against real per-test+coverage on this repository, over a slice with completeper-test attribution (37 test files, 159 production files).| Question | Precision | Sample |diff --git a/docs/architecture/test-intelligence.md b/docs/architecture/test-intelligence.mdindex da61c21b1..407c12737 100644--- a/docs/architecture/test-intelligence.md+++ b/docs/architecture/test-intelligence.md@@ -44,7 +44,7 @@ used", which a mention answers; this asks "is this run".The **import graph** is the weaker tier: importing a module pulls in everysymbol it defines while the test may touch one function.-Measured against a real `coverage run --contexts=test` on this repository, over+Measured against real per-test coverage on this repository, overthe slice where per-test attribution is complete, both sides seeing the same37 test files and 159 provably executed production files.diff --git a/docs/business/COMMERCIAL.md b/docs/business/COMMERCIAL.mdindex 85c098d59..55826d6fc 100644--- a/docs/business/COMMERCIAL.md+++ b/docs/business/COMMERCIAL.md@@ -84,8 +84,8 @@ All of the following ship in `pip install repowise` today, free for internal useLCOV / Cobertura / Clover / JaCoCo / Go coverprofile like a coverage service,then does the half a coverage service structurally cannot: answers *whichtests reach this file* and *which tests does this diff exercise* **with no- report at all**, at **95.7% and 97.5% precision** measured against a real- `coverage run --contexts=test`. Measured and inferred rows are labelled and+ report at all**, at **95.7% and 97.5% precision** measured against real+ per-test coverage. Measured and inferred rows are labelled andnever averaged. Zero LLM calls, no CI integration needed.([TEST_INTELLIGENCE.md](../layers/TEST_INTELLIGENCE.md))- **Change evidence and governance**: Change Records with an evidence checklistdiff --git a/docs/layers/TEST_INTELLIGENCE.md b/docs/layers/TEST_INTELLIGENCE.mdindex c1c1ab79e..357ddf2e8 100644--- a/docs/layers/TEST_INTELLIGENCE.md+++ b/docs/layers/TEST_INTELLIGENCE.md@@ -17,7 +17,7 @@ report (see [Patch coverage in CI](#patch-coverage-in-ci)).```bash# 1. Produce a report. Any supported format works.pytest --cov --cov-report=lcov:coverage.lcov-coverage run --contexts=test -m pytest # also records which test ran each line+pytest --cov=<package> --cov-context=test # also records which test ran each line (needs pytest-cov)# 2. Ingest it.repowise coverage add coverage.lcovrepowise coverage add .coverage # per-file coverage + per-test map@@ -57,7 +57,7 @@ test functions nearest each function in the call graph as runnable selectors| **LCOV** | Yes, when each record carries a non-blank `TN:` test name || **Cobertura**, **Clover** and **JaCoCo** XML | No || **Go coverprofile** (`go test -coverprofile`) | No |-| **coverage.py `.coverage`** | Yes, when written with `--contexts` |+| **coverage.py `.coverage`** | Yes, when recorded with per-test contexts || **Normalized JSON** (`repowise-coverage-v1`) | No |The format is sniffed from the file@@ -85,7 +85,7 @@ did not map. The coverage summary (`get_health`, the REST coverage route) reporteach report mapped and whether it was measured at the indexed commit.**Building a per-test map.** The main path is coverage.py dynamic contexts:-`coverage run --contexts=test -m pytest`, then `repowise coverage add .coverage`.+`pytest --cov=<package> --cov-context=test` (needs pytest-cov), then `repowise coverage add .coverage`.Contexts like `tests/test_auth.py::TestLogin::test_ok|run` become test ids, with noruntime dependency on coverage.py. Per-test LCOV works too: each record carries adistinct `TN:` name, and blank `TN:` records are skipped. If the report has no contexts,diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.mdindex 37acd974d..58aa31a1d 100644--- a/docs/reference/CLI_REFERENCE.md+++ b/docs/reference/CLI_REFERENCE.md@@ -1363,7 +1363,8 @@ JaCoCo XML, a Go coverprofile (`go test -coverprofile`), or a coverage.py`coverage.out`, `target/site/jacoco/jacoco.xml`, and similar reports when nopath is given, andmerges multiple reports (hit wins). When the report carries per-test contexts,-a coverage.py `.coverage` written with `coverage run --contexts=test`, or a+a coverage.py `.coverage` recorded with per-test contexts+(`pytest --cov=<package> --cov-context=test`, needs pytest-cov), or aper-test lcov, `add` also builds the per-test *test-to-code map*, which testcovers which source lines. A report without contexts still ingests theper-file coverage; it just skips the map.@@ -1375,7 +1376,7 @@ repowise coverage add web.lcov api.lcov # merged, hit winsrepowise coverage add 'artifacts/**/lcov.info' # every shard's reportrepowise coverage add web/coverage/lcov.info=web # report paths are relative to web/repowise coverage add --verbose # show ingestion debug logs-coverage run --contexts=test -m pytest # produce .coverage with contexts+pytest --cov=<package> --cov-context=test # produce .coverage with contexts (needs pytest-cov)repowise coverage add .coverage # per-file coverage + per-test maprepowise coverage status # coverage summary + "Test-to-code map" countsrepowise coverage status --format json # machine-readable (note: the --format on `coverage add` names the input parser instead)diff --git a/docs/reference/MCP_RESPONSE_FIELDS.md b/docs/reference/MCP_RESPONSE_FIELDS.mdindex 39750c7c2..e19e1c307 100644--- a/docs/reference/MCP_RESPONSE_FIELDS.md+++ b/docs/reference/MCP_RESPONSE_FIELDS.md@@ -286,7 +286,7 @@ Every float is rounded to 4 significant digits. Direct rows' `structural_score``files` lists up to 10 analysed files, largest structure move first, each with `base_score`, `head_score`, `base_structure`, `head_structure` (structure deduction), `nloc_base` and `nloc_head`; a side the file is missing on reads null. `files_total` counts them all. `score_basis` is `structure_only`: each score is 10 minus the structure deduction, the reading `get_health(counts="code_shape")` gives, from two passes that read no git history or coverage. A deleted file has a base-only row, with `moved_to` naming where its code went when it was split. `score_change` averages files scored on both sides, weighted by base nloc so a file that grows while improving keeps its gain: `base`, `head`, `delta` (two decimals), `structure_delta` (the deduction change, which still moves when a file sits on the 1.0 floor) and `files_compared`.-**impacted_tests.** The selection `repowise impacted-tests` makes, over every path the change touched whatever the score's filters, less the repowise output the score also leaves out (the index, and a managed file whose only change is repowise's block or entry), which the CLI still reads when tracked. `status` is `selected` or `run_all` (or `no_index`, `unknown`, `config_invalid`, `timeout`, `busy`, `no_source_line_changes` when nothing was selected, each with `run_all` true; `timeout` means the selection took over 30 seconds and `busy` that one for this repository is still running, and `repowise impacted-tests` gives the answer); `run_all` true means no subset can be vouched for, with up to three `reasons` (`reasons_total` counts them all). `tests_to_run` (capped at ten, `total` and `truncated`) is in `repowise impacted-tests`' [run order](CLI_REFERENCE.md#repowise-impacted-tests-revspec), the `always_run_total` tests that run with every subset last; `why` gives each listed file's reason. With `run_all` the list is what to run first. `tests_to_run_kind` is `test_id` when a coverage node id is listed, else `test_file`. `basis` is `measured` when coverage decided a changed file, `inferred` when only the graph or a rule did, `none` when nothing named a test; `basis_by_file` names the evidence per changed file (`coverage`, `changed-test`, `call-graph`, `import-graph`, `conftest`, `full-run`, `no-tests-needed`, ...). With a coverage map, `map_present` is true and `line_coverage` buckets the scored files' changed lines, matched on the side of the diff the map was measured at (by file when it was measured at neither): `untested_changes`, `stale_test_candidates` (covered lines whose test file is absent from the diff), `covered`, `no_coverage_data`. Build the measured map with `coverage run --contexts=test` and `repowise coverage add`.+**impacted_tests.** The selection `repowise impacted-tests` makes, over every path the change touched whatever the score's filters, less the repowise output the score also leaves out (the index, and a managed file whose only change is repowise's block or entry), which the CLI still reads when tracked. `status` is `selected` or `run_all` (or `no_index`, `unknown`, `config_invalid`, `timeout`, `busy`, `no_source_line_changes` when nothing was selected, each with `run_all` true; `timeout` means the selection took over 30 seconds and `busy` that one for this repository is still running, and `repowise impacted-tests` gives the answer); `run_all` true means no subset can be vouched for, with up to three `reasons` (`reasons_total` counts them all). `tests_to_run` (capped at ten, `total` and `truncated`) is in `repowise impacted-tests`' [run order](CLI_REFERENCE.md#repowise-impacted-tests-revspec), the `always_run_total` tests that run with every subset last; `why` gives each listed file's reason. With `run_all` the list is what to run first. `tests_to_run_kind` is `test_id` when a coverage node id is listed, else `test_file`. `basis` is `measured` when coverage decided a changed file, `inferred` when only the graph or a rule did, `none` when nothing named a test; `basis_by_file` names the evidence per changed file (`coverage`, `changed-test`, `call-graph`, `import-graph`, `conftest`, `full-run`, `no-tests-needed`, ...). With a coverage map, `map_present` is true and `line_coverage` buckets the scored files' changed lines, matched on the side of the diff the map was measured at (by file when it was measured at neither): `untested_changes`, `stale_test_candidates` (covered lines whose test file is absent from the diff), `covered`, `no_coverage_data`. Build the measured map with `pytest --cov=<package> --cov-context=test` (needs pytest-cov) and `repowise coverage add`.**patch_coverage.** Present when the index stores coverage; the same computation and JSON shape `repowise coverage check --format json` gates on. `patch_coverage_pct` is null when no changed line is executable; files the report never names read `not_in_report`. `scope.freshness` is `stale` when coverage was measured at another commit than the change's head; then a file git shows changed since that commit reads `stale_file`, with no figures, and only untouched files keep theirs. `path_gates` judges the path-scoped gates in `coverage.gates`. Each file row carries `risk` (`fix_pressure`, `dependents`, `hotspot`, `bug_magnet`, `risky`, `reasons`, `basis`) and up to eight `hints` per uncovered range: `range`, `symbol`, up to three `tests` to extend, and a `basis` of `per_test` (measured), `call_graph` or `import_graph` (inferred). Without a `revspec`, it covers everything a push would bring, diffed from the merge-base with the default base branch.diff --git a/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-coverage.md b/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-coverage.mdindex e3d966a76..c04b6e7cf 100644--- a/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-coverage.md+++ b/packages/cli/src/repowise/cli/agent_targets/_data/codex_prompts/repowise-coverage.md@@ -55,6 +55,7 @@ repowise coverage check origin/main...HEAD --report coverage/lcov.info --fail-un- `coverage add` always stores per-file line/branch coverage.- The **per-test map** (needed by `/prompts:repowise-impacted-tests`) is built onlywhen the report carries per-test contexts — e.g. a coverage.py `.coverage`- written with `coverage run --contexts=test`, or a per-test lcov. Reports+ recorded with `pytest --cov=<package> --cov-context=test` (needs+ pytest-cov), or a per-test lcov. Reportswithout contexts ingest aggregates only; say so plainly.- After ingesting, suggest `repowise health --recompute` so untested-hotspot markers update.diff --git a/packages/cli/src/repowise/cli/commands/coverage_cmd.py b/packages/cli/src/repowise/cli/commands/coverage_cmd.pyindex 0976c8787..14a5a2f3c 100644--- a/packages/cli/src/repowise/cli/commands/coverage_cmd.py+++ b/packages/cli/src/repowise/cli/commands/coverage_cmd.py@@ -27,6 +27,7 @@ from repowise.cli.helpers import ()from repowise.cli.output import emit_json, format_option, notice_consolefrom repowise.core.analysis.health.coverage import PARSERS as COVERAGE_PARSERS+from repowise.core.analysis.health.coverage.contexts import PER_TEST_COVERAGE_COMMANDfrom repowise.core.workspace.update import get_head_commit@@ -110,7 +111,7 @@ def coverage_add(Stores per-file line/branch coverage, and additionally the per-test"test-to-code" map when a report carries contexts - a coverage.py- ``.coverage`` written with ``coverage run --contexts=test``, or a per-test+ ``.coverage`` recorded with ``pytest --cov --cov-context=test``, or a per-testlcov. The map is what answers "which tests exercise this change"; reportswithout contexts ingest per-file coverage only.@@ -158,7 +159,8 @@ def coverage_add(console.print("[yellow]No coverage report found.[/yellow] Looked for ""coverage/lcov.info, .coverage, **/cobertura.xml, and similar.\n"- "Generate one (e.g. [cyan]coverage run --contexts=test -m pytest[/cyan] "+ f"Generate one (e.g. [cyan]{PER_TEST_COVERAGE_COMMAND}[/cyan], "+ "which needs pytest-cov, ""or [cyan]cargo llvm-cov --lcov --output-path coverage/lcov.info[/cyan]) ""then re-run, or pass a path:\n"" [cyan]repowise coverage add path/to/report[/cyan]"@@ -284,7 +286,7 @@ def coverage_add(if _is_sqlite(report_path):console.print(f"[yellow]{report_path.name}: no per-test contexts "- f"(ran without --contexts=test); per-test map "+ f"(recorded without per-test contexts); per-test map "f"skipped.[/yellow]")continue@@ -435,8 +437,8 @@ def coverage_status(repo: str | None, fmt: str) -> None:console.print("[yellow]No coverage ingested.[/yellow] Run ""[cyan]repowise coverage add <report>[/cyan]. A .coverage file "- "recorded with [cyan]--contexts=test[/cyan] also builds the "- "per-test map."+ f"recorded with [cyan]{PER_TEST_COVERAGE_COMMAND}[/cyan] (needs pytest-cov) "+ "also builds the per-test map.")return@@ -479,7 +481,7 @@ def coverage_status(repo: str | None, fmt: str) -> None:else:console.print("[dim]No test-to-code map yet - record one with "- "[cyan]coverage run --contexts=test -m pytest[/cyan], then "+ f"[cyan]{PER_TEST_COVERAGE_COMMAND}[/cyan] (needs pytest-cov), then ""[cyan]repowise coverage add .coverage[/cyan].[/dim]")diff --git a/packages/cli/src/repowise/cli/commands/impacted_tests_cmd.py b/packages/cli/src/repowise/cli/commands/impacted_tests_cmd.pyindex 31df9cae5..6345ffa7c 100644--- a/packages/cli/src/repowise/cli/commands/impacted_tests_cmd.py+++ b/packages/cli/src/repowise/cli/commands/impacted_tests_cmd.py@@ -53,6 +53,7 @@ from repowise.cli.helpers import (silence_logs_for_machine_output_until_close,)from repowise.cli.output import emit_json+from repowise.core.analysis.health.coverage.contexts import PER_TEST_COVERAGE_COMMANDfrom repowise.core.analysis.test_collection import plan_scopes, read_checkout, selectfrom repowise.core.analysis.test_selection import RUNNERS@@ -395,7 +396,8 @@ def _print_map_state(result: dict) -> None:console.print("[yellow]No test-to-code map ingested.[/yellow] Run ""[cyan]repowise coverage add[/cyan] on a coverage.py report written with "- "[cyan]coverage run --contexts=test[/cyan] to get exact impacted tests. "+ f"[cyan]{PER_TEST_COVERAGE_COMMAND}[/cyan] (needs pytest-cov) to get exact "+ "impacted tests. ""Falling back to the dependency graph and filename patterns below.")elif not result["map_current"]:diff --git a/packages/core/src/repowise/core/analysis/health/coverage/contexts.py b/packages/core/src/repowise/core/analysis/health/coverage/contexts.pyindex 9629842e6..75c70fae6 100644--- a/packages/core/src/repowise/core/analysis/health/coverage/contexts.py+++ b/packages/core/src/repowise/core/analysis/health/coverage/contexts.py@@ -7,15 +7,14 @@ emitting one :class:`TestCoverage` per ``(test, file)`` pair.Two sources carry per-test data today:-- **coverage.py ``.coverage`` sqlite** written with- ``coverage run --contexts=test`` (static) or ``dynamic_context =- test_function`` (dynamic). The ``context`` table names each test; the+- **coverage.py ``.coverage`` sqlite** with per-test contexts (static or+ dynamic). The ``context`` table names each test; the``line_bits`` / ``arc`` rows are keyed by ``(file_id, context_id)``.- **lcov ``TN:`` records** - the test-name line, blank in most merged lcovbut populated by per-test lcov output.Both degrade loudly: a report produced *without* contexts (a plain lcov, or-``coverage run`` with no ``--contexts``) yields ``records=[]`` and+a ``.coverage`` without contexts) yields ``records=[]`` and``has_contexts=False`` so callers report "aggregate only, per-test featuresunavailable" rather than silently emitting nothing.@@ -32,6 +31,10 @@ from pathlib import Pathfrom .lcov import _normalize_pathfrom .model import ContextCoverageReport, TestCoverage+#: The command the CLI recommends for a ``.coverage`` with per-test contexts.+#: Needs pytest-cov; ``--cov-context=test`` names each context after its test.+PER_TEST_COVERAGE_COMMAND = "pytest --cov --cov-context=test"+# coverage.py sqlite files start with the standard SQLite magic header._SQLITE_MAGIC = b"SQLite format 3\x00"@@ -123,7 +126,7 @@ def parse_coverage_sqlite(db_path: str | Path) -> ContextCoverageReport:Reads the ``file`` / ``context`` / ``line_bits`` tables (falling back to``arc`` endpoints when the db was written in branch/arc mode). Only- non-empty contexts become records; a db written without ``--contexts``+ non-empty contexts become records; a db without contextshas a single empty context and comes back ``has_contexts=False``."""path = Path(db_path)@@ -137,7 +140,7 @@ def parse_coverage_sqlite(db_path: str | Path) -> ContextCoverageReport:contexts = {cid: ctx for cid, ctx in conn.execute("SELECT id, context FROM context")}named = {cid: ctx for cid, ctx in contexts.items() if ctx}if not named:- # Ran without --contexts: one empty context, aggregate only.+ # A .coverage without contexts: one empty context, aggregate only.return ContextCoverageReport(source_format="coverage.py", has_contexts=False)files = {fid: _normalize_path(p) for fid, p in conn.execute("SELECT id, path FROM file")}diff --git a/packages/core/src/repowise/core/analysis/health/coverage/model.py b/packages/core/src/repowise/core/analysis/health/coverage/model.pyindex 5c2861675..4d27ec713 100644--- a/packages/core/src/repowise/core/analysis/health/coverage/model.py+++ b/packages/core/src/repowise/core/analysis/health/coverage/model.py@@ -158,7 +158,7 @@ class ContextCoverageReport:"""Per-test records parsed from one context-carrying report.``has_contexts`` is the loud-degradation signal: a report run *without*- contexts (a plain lcov, or ``coverage run`` with no ``--contexts``)+ contexts (a plain lcov, or a ``.coverage`` without contexts)parses to ``records=[]`` and ``has_contexts=False`` so callers can say"aggregate only, per-test features unavailable" instead of silentlyemitting nothing.diff --git a/packages/core/src/repowise/core/analysis/test_reachability.py b/packages/core/src/repowise/core/analysis/test_reachability.pyindex 9377f0f05..ac9121a2d 100644--- a/packages/core/src/repowise/core/analysis/test_reachability.py+++ b/packages/core/src/repowise/core/analysis/test_reachability.py@@ -34,7 +34,7 @@ source file references it, which is real evidence and a much cruder one. A testimporting a module pulls in every symbol the module defines while the test bodymay touch one function.-Measured against a real ``coverage run --contexts=test`` on this repository,+Measured against real per-test coverage on this repository,over the slice where per-test attribution is complete and both sides see thesame 37 test files (159 production files provably executed):diff --git a/plugins/claude-code/commands/coverage.md b/plugins/claude-code/commands/coverage.mdindex 3fc767cd2..2ec9187f5 100644--- a/plugins/claude-code/commands/coverage.md+++ b/plugins/claude-code/commands/coverage.md@@ -56,6 +56,7 @@ repowise coverage check origin/main...HEAD --report coverage/lcov.info --fail-un- `coverage add` always stores per-file line/branch coverage.- The **per-test map** (needed by `/repowise:impacted-tests`) is built onlywhen the report carries per-test contexts — e.g. a coverage.py `.coverage`- written with `coverage run --contexts=test`, or a per-test lcov. Reports+ recorded with `pytest --cov=<package> --cov-context=test` (needs+ pytest-cov), or a per-test lcov. Reportswithout contexts ingest aggregates only; say so plainly.- After ingesting, suggest `repowise health --recompute` so untested-hotspot markers update.diff --git a/plugins/shared/commands/coverage.md b/plugins/shared/commands/coverage.mdindex 3db34a302..312fd7523 100644--- a/plugins/shared/commands/coverage.md+++ b/plugins/shared/commands/coverage.md@@ -57,6 +57,7 @@ repowise coverage check origin/main...HEAD --report coverage/lcov.info --fail-un- `coverage add` always stores per-file line/branch coverage.- The **per-test map** (needed by `{{cmd:impacted-tests}}`) is built onlywhen the report carries per-test contexts — e.g. a coverage.py `.coverage`- written with `coverage run --contexts=test`, or a per-test lcov. Reports+ recorded with `pytest --cov=<package> --cov-context=test` (needs+ pytest-cov), or a per-test lcov. Reportswithout contexts ingest aggregates only; say so plainly.- After ingesting, suggest `repowise health --recompute` so untested-hotspot markers update.diff --git a/tests/unit/cli/test_per_test_coverage_command.py b/tests/unit/cli/test_per_test_coverage_command.pynew file mode 100644index 000000000..b65d87579--- /dev/null+++ b/tests/unit/cli/test_per_test_coverage_command.py@@ -0,0 +1,57 @@+"""The per-test coverage command the CLI recommends (#3598).++coverage.py has no ``--contexts`` flag, so pasting the old suggestion failed.+Every message now uses one shared, working command, and says it needs+pytest-cov, which repowise does not install.+"""++from __future__ import annotations++import inspect++import pytest+from click.testing import CliRunner++from repowise.cli.commands import coverage_cmd, impacted_tests_cmd+from repowise.cli.main import cli+from repowise.core.analysis.health.coverage.contexts import PER_TEST_COVERAGE_COMMAND+++def _flat(text: str) -> str:+ # Rich wraps long lines; compare on single spaces.+ return " ".join(text.split())+++def test_the_recommended_command_is_a_real_pytest_cov_invocation() -> None:+ assert PER_TEST_COVERAGE_COMMAND == "pytest --cov --cov-context=test"++[email protected]("module", [coverage_cmd, impacted_tests_cmd])+def test_no_message_suggests_the_nonexistent_contexts_flag(module) -> None:+ assert "--contexts" not in inspect.getsource(module)+++def test_coverage_add_no_report_message_uses_the_shared_command(+ monkeypatch: pytest.MonkeyPatch, tmp_path+) -> None:+ monkeypatch.setattr(coverage_cmd, "_resolve_coverage_repo", lambda _p: tmp_path)+ monkeypatch.setattr(coverage_cmd, "ensure_repowise_dir", lambda _p: None)+ monkeypatch.setattr(coverage_cmd, "_discover_context_reports", lambda _p: [])++ result = CliRunner().invoke(cli, ["coverage", "add"])++ assert "No coverage report found" in result.output+ assert PER_TEST_COVERAGE_COMMAND in _flat(result.output)+ # pytest-cov is not a repowise dependency, so the message says it is needed.+ assert f"{PER_TEST_COVERAGE_COMMAND}, which needs pytest-cov" in _flat(result.output)+ assert "--contexts" not in result.output+++def test_impacted_tests_no_map_message_uses_the_shared_command(capsys) -> None:+ impacted_tests_cmd._print_map_state({"map_empty": True, "map_current": False})++ out = capsys.readouterr().out+ assert "No test-to-code map ingested" in out+ assert PER_TEST_COVERAGE_COMMAND in _flat(out)+ assert f"{PER_TEST_COVERAGE_COMMAND} (needs pytest-cov)" in _flat(out)+ assert "--contexts" not in out