Skip to content

fix(tests): mock shutil.which in SSHEnvironment unit tests - #34

Merged
dizhaky merged 1 commit into
mainfrom
fix/ssh-test-mock-shutil-which
Jun 27, 2026
Merged

fix(tests): mock shutil.which in SSHEnvironment unit tests#34
dizhaky merged 1 commit into
mainfrom
fix/ssh-test-mock-shutil-which

Conversation

@dizhaky

@dizhaky dizhaky commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes 7 failing unit tests in tests/tools/test_ssh_environment.py that require ssh to be installed
  • TestBuildSSHCommand and TestControlSocketPath fixtures patched subprocess.run/Popen but not shutil.which, so _ensure_ssh_available() raised RuntimeError on any host without the OpenSSH client (including the CI runner)
  • Add monkeypatch.setattr(ssh_env.shutil, "which", lambda _: "/usr/bin/ssh") to both _mock_connection fixtures — consistent with how TestSSHPreflight already does it

Test plan

🤖 Generated with Claude Code

https://claude.ai/code/session_019vSDPRFU42cowdoddTvC47


Generated by Claude Code

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.
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/ssh-test-mock-shutil-which vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8649 on HEAD, 8649 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4570 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@dizhaky
dizhaky marked this pull request as ready for review June 27, 2026 13:04
@dizhaky
dizhaky merged commit 5b1dfbc into main Jun 27, 2026
27 of 28 checks passed
@dizhaky
dizhaky deleted the fix/ssh-test-mock-shutil-which branch June 27, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant