From 4ca7c2104da006aa0eac8cd8199aad7b5c12851f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 9 May 2026 15:00:08 -0700 Subject: [PATCH] test(gateway): stub /proc unavailability in find_gateway_pids fallback test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up test fix for #22693 — the existing test for ps-failure + pid-file fallback needed the /proc walk path stubbed too since /proc is now consulted first. --- tests/hermes_cli/test_gateway.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/hermes_cli/test_gateway.py b/tests/hermes_cli/test_gateway.py index a8cbfabf4c5..225947994d2 100644 --- a/tests/hermes_cli/test_gateway.py +++ b/tests/hermes_cli/test_gateway.py @@ -419,6 +419,15 @@ def test_find_gateway_pids_falls_back_to_pid_file_when_process_scan_fails(monkey monkeypatch.setattr(gateway, "is_windows", lambda: False) monkeypatch.setattr("gateway.status.get_running_pid", lambda: 321) + # /proc walk is the first path tried (#22693). Force os.listdir on /proc + # to raise so the function falls back to ps, where fake_run takes over. + _real_listdir = gateway.os.listdir + def _no_proc_listdir(path): + if path == "/proc": + raise OSError("test stub: /proc unavailable") + return _real_listdir(path) + monkeypatch.setattr(gateway.os, "listdir", _no_proc_listdir) + def fake_run(cmd, **kwargs): if cmd[:4] == ["ps", "-A", "eww", "-o"]: return SimpleNamespace(returncode=1, stdout="", stderr="ps failed")