fix(tests): mock shutil.which in SSHEnvironment unit tests - #34
Merged
Conversation
TestBuildSSHCommand and TestControlSocketPath patched subprocess.run and subprocess.Popen but not shutil.which, so _ensure_ssh_available() raised RuntimeError on CI runners (and any env) where the OpenSSH client is not installed. Add monkeypatch.setattr(ssh_env.shutil, 'which', ...) to both _mock_connection fixtures so the 7 affected tests pass without requiring a real ssh binary.
🔎 Lint report:
|
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
tests/tools/test_ssh_environment.pythat requiresshto be installedTestBuildSSHCommandandTestControlSocketPathfixtures patchedsubprocess.run/Popenbut notshutil.which, so_ensure_ssh_available()raisedRuntimeErroron any host without the OpenSSH client (including the CI runner)monkeypatch.setattr(ssh_env.shutil, "which", lambda _: "/usr/bin/ssh")to both_mock_connectionfixtures — consistent with howTestSSHPreflightalready does itTest plan
test_ssh_environment.pypass (11 integration tests correctly skipped withoutTERMINAL_SSH_HOSTset)test (3)CI failure onmain(and on PR fix(memgw): pass user_id per-call to fix cross-user memory scoping (Codex P1) #33)🤖 Generated with Claude Code
https://claude.ai/code/session_019vSDPRFU42cowdoddTvC47
Generated by Claude Code