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")