Skip to content

The agent that grows with you

test: pay the cold import / state.db open before the timed coalescing and reap waits

teknium1436f7dfa9646
diff --git a/tests/hermes_cli/test_profiles_sidebar_cache.py b/tests/hermes_cli/test_profiles_sidebar_cache.py
index 4abdafdff2f..67f24ad7678 100644
--- a/tests/hermes_cli/test_profiles_sidebar_cache.py
+++ b/tests/hermes_cli/test_profiles_sidebar_cache.py
@@ -190,6 +190,10 @@ class SidebarCacheTests(unittest.TestCase):
self.assertTrue(release.wait(timeout=2))
return None
+ # The handler lazy-imports tui_gateway.server on first use (~1 s cold under a loaded host);
+ # pay that before the burst so the wait below measures coalescing, not import time.
+ import tui_gateway.server # noqa: F401
+
with mock.patch.object(profiles, "_profile_targets", return_value=[("default", Path("/nonexistent"))]), \
mock.patch.object(profiles, "_read_profile_db", side_effect=fake_read), \
ThreadPoolExecutor(max_workers=workers) as pool:
diff --git a/tests/tui_gateway/test_tui_gateway_server.py b/tests/tui_gateway/test_tui_gateway_server.py
index e7f3ecc7484..b83b1d48d54 100644
--- a/tests/tui_gateway/test_tui_gateway_server.py
+++ b/tests/tui_gateway/test_tui_gateway_server.py
@@ -5338,6 +5338,9 @@ def test_ws_orphan_reap_releases_resume_lock_before_slow_teardown(monkeypatch):
monkeypatch.setattr(server, "_WS_ORPHAN_REAP_GRACE_S", 0.01)
monkeypatch.setattr(server.threading, "Timer", _Timer)
monkeypatch.setattr(server, "_teardown_session", _slow_teardown)
+ # The reap's delegation check reads the session row from the launch store; open that handle
+ # before the timer fires so the wait below measures lock release, not a cold state.db open.
+ server._get_db()
server._sessions["slow-orphan"] = _session(
transport=server._detached_ws_transport,
running=False,