mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 14:27:49 +01:00
43 tests, no production change - the module is byte-identical to HEAD. This lands separately from the split that follows because a split verified by tests written in the same commit proves nothing: the tests would have been written against the post-split shape. Covers every function, and specifically the branches a happy-path test misses: zero-length window and cpu_count() -> None in _cpu_table, non-positive RSS and the CPU/pid tie-break in _dedupe_ram, the sibling truncation boundary in _ram_table, zero total_samples in _gpu_table, OSError and unparseable MemTotal in _host_profile, and the single-sample unknown-interval path in _methodology_section and _render_report. _host_profile is the only impure function; its /proc reads go through a monkeypatched Path.open and nvidia-smi is stubbed at the _run seam, so no test touches the disk or forks. 117 stmts / 28 branches, 0 missed. linux_configuration/tests: 100 -> 143 passing. No suppressions: two ANN401s were removed by typing the helper kwargs explicitly rather than silencing them, and a mypy ignore went away with a fallback branch no caller reached. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
40 lines
4.0 KiB
JSON
40 lines
4.0 KiB
JSON
{
|
|
"intent": "Take _usage_report_render.py from 21% to 100% line and branch coverage, so that the split which follows can be verified against tests that were written before the seam existed.",
|
|
"scope": [
|
|
"New file linux_configuration/tests/test_usage_report_render.py - 43 tests",
|
|
"No change to any production file. _usage_report_render.py is byte-identical to HEAD.",
|
|
"Non-goal: the split itself, which is a separate commit for exactly the reason this one exists"
|
|
],
|
|
"changes": [
|
|
"Added 43 tests covering every function in the module: _fmt_h (8 parametrised cases pinning the 3600 s and 60 s unit boundaries), _md_escape, _cpu_table, _dedupe_ram, _ram_table, _gpu_table, _host_profile, _fingerprint_section, _methodology_section and _render_report.",
|
|
"Covered the branches that a happy-path test would miss: zero-length window and os.cpu_count() returning None in _cpu_table, non-positive RSS and the CPU/pid_count tie-break in _dedupe_ram, the sibling-list truncation boundary in _ram_table, zero total_samples in _gpu_table, OSError and unparseable MemTotal in _host_profile, and the single-sample unknown-interval path in both _methodology_section and _render_report.",
|
|
"_host_profile is the only impure function. Its two /proc reads are redirected through a monkeypatched Path.open returning canned text, and the nvidia-smi call is stubbed at the _run seam, so the tests never touch the real filesystem or spawn a subprocess - per the repo convention of mocking external calls.",
|
|
"No lint suppression was used. Two ANN401 findings were removed by replacing **kwargs: Any passthrough helpers with explicit typed keyword parameters, and a mypy arg-type ignore was removed by deleting a real-filesystem fallback branch that no caller reached."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "pytest linux_configuration/tests/test_usage_report_render.py --cov=_usage_report_render --cov-branch --cov-report=term-missing",
|
|
"result": "pass",
|
|
"evidence": "Before this commit the same coverage command over the four existing usage_report test files reported: 117 stmts, 87 miss, 28 branch, 1 BrPart, 21%, missing 30-61, 66, 75-79, 83-104, 114-127, 131-159, 163-185, 189-190, 203-238, 273-310. After: 117 stmts, 0 miss, 28 branch, 0 BrPart, 100%, nothing missing. 43 passed."
|
|
},
|
|
{
|
|
"command": "pytest linux_configuration/tests/ (whole directory)",
|
|
"result": "pass",
|
|
"evidence": "143 passed, up from 100 at HEAD - exactly the 43 tests added and no collateral change. The pre-existing 34 usage_report tests across the four sibling files still pass untouched."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files linux_configuration/tests/test_usage_report_render.py",
|
|
"result": "pass",
|
|
"evidence": "All applicable hooks pass, including ruff, ruff format, mypy, 'Block noqa comments', 'Block ruff noqa file-level comments' and 'python tests naming'. grep for 'noqa|type: ignore' in the new file returns 0."
|
|
}
|
|
],
|
|
"risks": [
|
|
"Two of the 43 assertions initially failed against correct production code and were fixed in the test, not the source: a comma count that mis-stated how many separators join N names, and an assertion that 'GPU SM-seconds' is absent from a GPU-less report when that phrase also legitimately appears in the methodology prose. The second now asserts on the table header cell '| GPU SM-seconds |' instead. Both were my errors; no production behaviour was changed to make a test pass.",
|
|
"_host_profile's tests monkeypatch Path.open globally for the duration of each test. The fake raises KeyError for any path the test did not stub, which is deliberate - it fails loudly if the function starts reading a third file rather than silently falling through to the real disk."
|
|
],
|
|
"rollback": [
|
|
"git rm the test file. No production code depends on it.",
|
|
"After rollback, coverage of _usage_report_render.py returns to 21% and linux_configuration/tests reports 100 passing tests. Note that rolling this back while keeping the subsequent split commit would leave that split unverified."
|
|
]
|
|
}
|