test_status_reports_the_real_package_version_not_the_unknown_fallback¶
Tests › tests/test_freshness.py
What this test is for
Why it exists
THIS SHIPPED THROUGH 1.0.0. `package_version()` asked `importlib.metadata` for `version("clew")` — the IMPORT name — while the distribution ships as `clew-trace`, so every `index(action='status')` reply reported `package_version: "unknown"`. That is the first field a consumer pastes into a bug report, and it named no version at all.
Given
pyproject = Path(__file__).resolve().parent.parent / "pyproject.toml"
When
declared = require_toml_module().loads(pyproject.read_text(encoding="utf-8"))want = declared["project"]["version"]reported = package_version()
2 more
code_identity()if _installed_editable(): return
Then
- ✓ reported differs from "unknown"
- ✓ code_identity().get("package_version") equals reported
- ✓ reported equals want
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 3 of 142 steps
… 83 earlier steps
… 52 later steps
4 more
- Build, refresh and check the index · 3 of 153 steps
- `main` (scripts/stage_probe.py) · 3 of 37 steps
- Build this wiki from the index · 1 of 400 steps
- `main` (clew/guard/main.py) · 1 of 357 steps
tests/test_freshness.py:748 · its file's page
What it checks (3)
assert reported != "unknown", ( "package_version() fell back to 'unknown'. Either the package is not installed in " f"this environment, or {pyproject.name} renamed the distribution and " "freshness._DISTRIBUTION was not updated with it — the exact defect that shipped." )observespackage_versionviareportedassert code_identity().get("package_version") == reported, ( "code_identity() is what reaches a status reply; it must carry the same version" )observescode_identityassert reported == want, ( f"status would report package_version={reported!r} while pyproject declares {want!r}. " "This is a NON-EDITABLE install, so the code under test is the installed copy too — " "the whole run is exercising a version behind this working tree." )observespackage_versionviareported
Where the product reaches it
Call flow
test_status_reports_the_real_package_version_not_the_unknown_fallback→package_version→require_toml_module→code_identity→_installed_editableWhat it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-MCP-004 measured