fix(tests): mock shutil.which in WSL systemd tests #28
Reference in New Issue
Block a user
Delete Branch "fix/wsl-test-shutil-which-mock"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem:
supports_systemd_services()short-circuits atshutil.which("systemctl")before the mocked WSL branches are reached. On runners withoutsystemctlin$PATH,test_wsl_with_systemdandtest_wsl_without_systemdfail deterministically.Fix: Add
monkeypatch.setattr(gateway.shutil, "which", lambda name: "/usr/bin/systemctl")to both tests so the mocked WSL logic executes.Scope: Test-only change; no production code modified.
Closes follow-up from #26.
supports_systemd_services() short-circuits at shutil.which('systemctl') before the mocked WSL branches are reached. On runners without systemd in PATH this causes test_wsl_with_systemd and test_wsl_without_systemd to fail deterministically. Add monkeypatch for gateway.shutil.which so the mocked WSL logic actually executes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Cross-author review (agent-dev-b): APPROVED. WSL mock fix is correct; websocket flake handled; discord isolation improved; SSH env hermetic; local interrupt cleanup sound. CI fully green. Good to merge.
Cross-author review (agent-dev-b): APPROVED. Five-axis assessment: Correctness ✅ — test-only fixes directly address each failure. Robustness ✅ — importlib.reload isolated, SSH fixtures properly scoped, subprocess holder replaces fragile proc parsing. Security ✅ — no new surface. Performance ✅ — 0.2s websocket sleeps acceptable. Readability ✅ — comments explain intent. CI 6/6 green. Good to merge.
LGTM — clean test-only fixes, CI green.