test: cover _auto_classify_files timeout + invalid-element message#129
Merged
Conversation
…sage (#6156) Two test-coverage gaps in the pt handoff command (#6151 follow-up): 1. _auto_classify_files() in scripts/pt.py has tests for FileNotFoundError and non-zero-exit branches but no test for subprocess.TimeoutExpired. Add test_auto_files_warns_on_git_timeout that monkeypatches subprocess.run to raise TimeoutExpired and asserts the "timed out" warning appears in stderr with file_list == []. Mirrors the existing branch-test pattern. 2. test_handoff_create_files_invalid_element_type only checked exit code and error.class. Its two siblings (missing_required_keys and unknown_classification) both assert message content. Add the parallel assertion: "element 0" in payload["error"]["message"]. No production code changes. Closes #6156. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_auto_files_warns_on_git_timeoutto cover thesubprocess.TimeoutExpiredbranch inscripts/pt.py:_auto_classify_files()(4695-4701). The function emits"warning: git status timed out at 10s, ..."to stderr and returns[]; this test pins that behaviour for--auto-fileshandoff creation. Pattern mirrors the existingtest_auto_files_warns_on_git_missing/test_auto_files_warns_on_git_nonzero_exit.assert "element 0" in payload["error"]["message"]totest_handoff_create_files_invalid_element_typefor parity with the two sibling tests (test_handoff_create_files_missing_required_keys,test_handoff_create_files_unknown_classification) which both assert message content.No production code changes.
Test plan
pytest tests/test_handoff_cli.py::test_auto_files_warns_on_git_timeoutpassespytest tests/test_handoff_cli.py::test_handoff_create_files_invalid_element_typepasses with the new assertionRelated