From 629c33c633a12e43e9a334fbd07a973b317c950e Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 12 May 2026 11:51:37 -0700 Subject: [PATCH] test(gateway): patch _pid_exists instead of os.kill for scoped-lock tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-#21561 the liveness probe in acquire_scoped_lock() routes through gateway.status._pid_exists (psutil-first, safe on Windows), not os.kill(pid, 0). The two new macOS regression tests were patching status.os.kill, which had no effect — the unmocked psutil call returned False for PID 99999, marking the lock stale before the new code branch ran. The 'replaces' test passed only because acquired=True was already the expected outcome; the 'keeps' test failed in CI. Switch both tests to monkeypatch status._pid_exists directly, matching the existing test_acquire_scoped_lock_rejects_live_other_process pattern, so they actually exercise the new start_time=None + cmdline-based staleness branch. --- tests/gateway/test_status.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/gateway/test_status.py b/tests/gateway/test_status.py index 8a603260205..91a52104ded 100644 --- a/tests/gateway/test_status.py +++ b/tests/gateway/test_status.py @@ -462,7 +462,10 @@ class TestScopedLocks: "argv": ["/Users/user/.hermes/hermes-agent/hermes_cli/main.py", "gateway", "run", "--replace"], })) - monkeypatch.setattr(status.os, "kill", lambda pid, sig: None) + # Post-#21561 the liveness probe routes through + # ``gateway.status._pid_exists`` (psutil-first, safe on Windows), + # not ``os.kill``. + monkeypatch.setattr(status, "_pid_exists", lambda pid: True) monkeypatch.setattr(status, "_get_process_start_time", lambda pid: None) monkeypatch.setattr(status, "_looks_like_gateway_process", lambda pid: False) @@ -485,7 +488,7 @@ class TestScopedLocks: "argv": ["/Users/user/.hermes/hermes-agent/hermes_cli/main.py", "gateway", "run", "--replace"], })) - monkeypatch.setattr(status.os, "kill", lambda pid, sig: None) + monkeypatch.setattr(status, "_pid_exists", lambda pid: True) monkeypatch.setattr(status, "_get_process_start_time", lambda pid: None) monkeypatch.setattr(status, "_looks_like_gateway_process", lambda pid: True)