From a2a16dfdacc3616c473ef56a905913ce99cb81e0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 21:15:00 -0700 Subject: [PATCH] test(bot-relay): live-Bot-Chat deliver test ignores the server's import-time git prefetch tui_gateway.server kicks off prefetch_update_check() at import, which runs `git rev-parse`/`rev-list` on a daemon thread. The test patched subprocess.run with a fake that returned None and recorded every call, so whenever that thread landed inside the test window the assertion saw a `git` argv and the thread crashed on `.returncode` (red on main since 6e775907d78 made the fetch slower). Filter to non-git spawns and return a real-shaped proc for everything. --- tests/tui_gateway/test_bot_relay_methods.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/tui_gateway/test_bot_relay_methods.py b/tests/tui_gateway/test_bot_relay_methods.py index 85b18d971a..8b551892f9 100644 --- a/tests/tui_gateway/test_bot_relay_methods.py +++ b/tests/tui_gateway/test_bot_relay_methods.py @@ -116,7 +116,18 @@ def test_deliver_lands_in_live_bot_chat_instead_of_subprocess(home, monkeypatch) """ spawned = [] submitted = [] - monkeypatch.setattr("subprocess.run", lambda *a, **k: spawned.append(a) or None) + + class _Proc: + returncode, stdout, stderr = 0, "pong", "" + + def _fake_run(argv, *a, **k): + # The server module's import-time update prefetch runs `git ...` on a + # daemon thread; only the relay's `hermes` CLI spawn is under test. + if argv and argv[0] != "git": + spawned.append(argv) + return _Proc() + + monkeypatch.setattr("subprocess.run", _fake_run) monkeypatch.setitem( srv._methods, "prompt.submit", lambda rid, p: submitted.append(p) or srv._ok(rid, {"status": "streaming"}) ) @@ -137,10 +148,6 @@ def test_deliver_lands_in_live_bot_chat_instead_of_subprocess(home, monkeypatch) srv._sessions["live-ops"]["pending_title"] = "Scratch" submitted.clear() - class _Proc: - returncode, stdout, stderr = 0, "pong", "" - - monkeypatch.setattr("subprocess.run", lambda *a, **k: spawned.append(a) or _Proc()) out = _result(srv._methods["bot_relay.deliver"](2, {"profile": "ops", "message": "ping"})) assert out["reply"] == "pong" and spawned and not submitted