{ "intent": "Cover transcribe_helpers.py from 0% to 100% line and branch, so the following split of the 289-line file is verified against tests written before the seam existed.", "scope": [ "New: linux_configuration/tests/test_transcribe_{probes,model_ops,wav,helpers_cli}.py", "linux_configuration/tests/conftest.py - added the tools/ dir to sys.path and two shared doubles as fixtures", "Non-goal: any change to transcribe_helpers.py, which is byte-identical to HEAD", "Non-goal: moving these files under python_pkg/" ], "changes": [ "Added the tools/ directory to the existing _SCRIPT_DIRS list in conftest.py, the same mechanism already used for the usage_report bin/ modules.", "Added 41 tests covering the dependency probes, the sine-WAV generator, model preparation, the CUDA probe, and all eight CLI subcommands with their exit codes.", "Patched only at the _try_import seam, so no ML package is needed: the module reaches faster_whisper, torch, speechbrain, soundfile, ctranslate2 and huggingface_hub exclusively through it. Verified by an AST scan at every nesting level - the only direct numpy imports in the package sit under TYPE_CHECKING and never execute.", "Shared doubles live in conftest.py as fixtures rather than an importable helper module: name-tests-test requires every .py under tests/ to be named test_*.py, and conftest is not importable by name.", "Split the tests across four files rather than one, because a single module reached 291 lines - over the cap this work exists to clear." ], "verification": [ { "command": "git diff --stat -- .../tools/transcribe_helpers.py", "result": "pass", "evidence": "No change: this commit adds tests only." }, { "command": "pytest linux_configuration/tests/test_transcribe_*.py --cov=transcribe_helpers --cov-branch --cov-report=term-missing", "result": "pass", "evidence": "41 passed. transcribe_helpers.py: 118 statements, 0 missing, 26 branches, 0 partial, 100%. The last gap was the dispatch guard at line 284, unreachable through the CLI because argparse's choices list and the dispatch dict carry the same eight commands; it is covered by admitting a ninth choice, which also documents why the guard exists." }, { "command": "pytest linux_configuration/tests/test_transcribe_*.py (count across the test-file split)", "result": "pass", "evidence": "41 passed both before and after splitting the 291-line module into four, which is the discriminating check for a test-file split: a file outside the runner's glob would be silently uncollected." }, { "command": "python3 transcribe_helpers.py python-version && python3 transcribe_helpers.py check-faster-whisper", "result": "pass", "evidence": "Prints 3.14, then exits 7 with the offline-mode message - 7 being the code transcribe.sh branches on. Confirms the real entry point still works on a machine with no ML dependencies." }, { "command": "python3 transcribe_helpers.py generate-wav --file /tone.wav", "result": "pass", "evidence": "Wrote a 96044-byte WAV, matching 16000 Hz x 3 s x 16-bit mono plus header." }, { "command": "pytest linux_configuration/tests/ -q", "result": "pass", "evidence": "243 passed, up from 202 by exactly the 41 tests added; no existing test was altered." }, { "command": "pre-commit run --files ", "result": "pass", "evidence": "All hooks pass. Fixed rather than suppressed: three FBT001 boolean-positional warnings became keyword-only parameters, an S108 hardcoded /tmp path became tmp_path, a mypy func-returns-value error from an append-inside-or expression became a named function, and three noqa: N802 comments were removed by exposing the third-party CamelCase name through __getattr__ instead of defining it." }, { "command": "bash ~/utils/scripts/check_file_length.sh --all", "result": "pass", "evidence": "35 files over cap, unchanged by this commit. New test files are 223/122/108/58 lines, all under 250." } ], "risks": [ "The tests stub every ML dependency, so they prove the control flow and the exit-code contract, not that faster_whisper itself behaves as expected. That is deliberate: the packages are absent in CI, and a real model download is not a unit test.", "conftest.py now grows shared doubles alongside its sys.path bootstrap. Acceptable because name-tests-test forbids a helper module under tests/, and the alternative is duplicating the double in two files." ], "rollback": [ "git revert the commit; the four test files and the conftest additions disappear together.", "After rollback, confirm pytest linux_configuration/tests/ reports 202 passed and that transcribe_helpers.py is unchanged." ] }