mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 20:54:00 +01:00
test_display.py 363 -> 204, with the supply maths and its display going to test_supply_levels.py. test_usb_query.py 328 -> 126, with the retry and sequencing tests going to test_usb_query_sequence.py. That removed the last reader of the six _supply names through display, so display.py's __all__ shrinks to the two public entry points and the stale comment about tests reaching them there is gone. Checked by grep across python_pkg and an import-time attribute probe, not by the suite. The first run after the usb_query split reported 393: TestParsePagecount sat between the two moved classes and travelled with them. Fixed. Pass count is 402 before and after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
54 lines
4.3 KiB
JSON
54 lines
4.3 KiB
JSON
{
|
|
"intent": "Bring the display and usb_query test modules under the 250-line cap, and remove the re-export block in display.py that the earlier partial split left behind.",
|
|
"scope": [
|
|
"python_pkg/brother_printer/tests/test_display.py (363 -> 204)",
|
|
"python_pkg/brother_printer/tests/test_supply_levels.py (new)",
|
|
"python_pkg/brother_printer/tests/test_usb_query.py (328 -> 126)",
|
|
"python_pkg/brother_printer/tests/test_usb_query_sequence.py (new)",
|
|
"python_pkg/brother_printer/tests/test_usb_query_part2.py -> test_pjl_io.py (rename only)",
|
|
"python_pkg/brother_printer/display.py (dead re-export removed)",
|
|
"Non-goal: no assertion changed, no test deleted, skipped or weakened"
|
|
],
|
|
"changes": [
|
|
"test_display.py split at TestClassifyPercentageLevel: the USB report tests stay, the consumable supply maths and its display go to test_supply_levels.py, which imports the six classification helpers from _supply directly and the two printing functions from display.",
|
|
"That was the last reader of the six _supply names through display, so display.py's __all__ shrank to the two public entry points, its _supply import narrowed to the one name it actually calls, and the stale comment claiming the tests reach those names through this module was deleted. Confirmed by grep across python_pkg that no source module or test still imports them from display.",
|
|
"test_usb_query.py split at TestRetryPjlQuery: discovery and PJL response parsing stay, the retry, sequencing, result init and query_usb_pjl tests go to test_usb_query_sequence.py. Those patch the wire helpers on usb_query rather than _pjl_io, which is correct - that is the module whose globals the sequencing code resolves them through.",
|
|
"Renamed test_usb_query_part2.py to test_pjl_io.py, matching the module it has covered since the source split."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "PYTHONPATH=. python3 -m pytest python_pkg/brother_printer/tests -q",
|
|
"result": "pass",
|
|
"evidence": "402 passed before the split and 402 passed after it - identical pass count."
|
|
},
|
|
{
|
|
"command": "PYTHONPATH=. python3 -m pytest python_pkg/brother_printer/tests -q (first run after the usb_query split)",
|
|
"result": "fail then pass",
|
|
"evidence": "Reported 9 failed, 393 passed: TestParsePagecount sat between the two moved classes and travelled with them, so the new module needed errno, os, _parse_status and _parse_pagecount that my hand-written import block had not anticipated. Added; the count returned to 402."
|
|
},
|
|
{
|
|
"command": "PYTHONPATH=. python3 -c \"from python_pkg.brother_printer import display as d; d._display_report_header; d._display_supply_levels; d._display_supply_warnings; d._display_network_device_info; d._display_page_count_estimate; d.display_cups_queue_status; d.get_status_info\"",
|
|
"result": "pass",
|
|
"evidence": "runtime probe OK after the __all__ removal - every name the two display test modules patch is still a real attribute, so shrinking the re-export did not expose them to ruff's F401/TC001 rewrite."
|
|
},
|
|
{
|
|
"command": "grep -rn 'display import' python_pkg/",
|
|
"result": "pass",
|
|
"evidence": "Only check_brother_printer.py, test_display.py, test_display_part2.py and test_supply_levels.py import from display, and none of them names a _supply helper - which is what made the __all__ entries safe to drop rather than merely unused-looking."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <the touched files and artifacts>",
|
|
"result": "pass",
|
|
"evidence": "ruff removed two imports the split left unused in test_usb_query.py; clean on re-run, and pytest-with-coverage passes."
|
|
}
|
|
],
|
|
"risks": [
|
|
"Removing names from __all__ is the one edit here that could break a caller silently at import time rather than loudly. Guarded by the repo-wide grep and the attribute probe, not by the test run alone.",
|
|
"test_usb_query_sequence.py patches _drain_buffer and pjl_query on usb_query while test_pjl_io.py patches their definitions on _pjl_io. Both are correct and must stay that way; collapsing them onto one module would unpatch the other caller."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; the two originals return at 363 and 328 lines, display.py's __all__ comes back, and the two new modules disappear.",
|
|
"After rollback, re-run the package suite and confirm it still reports 402 passed."
|
|
]
|
|
}
|