From 244dabbd9c4b542bf5c1ad0159af512c2b5d6e08 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Mon, 20 Jul 2026 12:53:57 +0530 Subject: [PATCH] test(cli): mock _cleanup_oneshot_runtime in all _run_and_exit tests Phase 2c found 3 tests that called _run_and_exit_oneshot without mocking _cleanup_oneshot_runtime, causing real cleanup (terminal, browser, MCP, auxiliary) to run in the pytest worker. Add the mock to all three for test isolation. Also remove redundant 'import logging' inside _exit_after_oneshot (already imported at module level, line 729). --- hermes_cli/main.py | 1 - tests/hermes_cli/test_tui_resume_flow.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 7ce7ece58d6..25ea651b2e4 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -82,7 +82,6 @@ def _exit_after_oneshot(rc: object) -> None: except Exception: pass try: - import logging logging.shutdown() except Exception: pass diff --git a/tests/hermes_cli/test_tui_resume_flow.py b/tests/hermes_cli/test_tui_resume_flow.py index d171ab3d14a..d30b1bb7c83 100644 --- a/tests/hermes_cli/test_tui_resume_flow.py +++ b/tests/hermes_cli/test_tui_resume_flow.py @@ -805,6 +805,7 @@ def test_run_and_exit_oneshot_routes_system_exit_to_hard_exit(monkeypatch, main_ "hermes_cli.oneshot", types.SimpleNamespace(run_oneshot=fake_run_oneshot), ) + monkeypatch.setattr(main_mod, "_cleanup_oneshot_runtime", lambda: None) monkeypatch.setattr(main_mod, "_exit_after_oneshot", lambda rc: exits.append(rc)) main_mod._run_and_exit_oneshot("hello") @@ -844,6 +845,7 @@ def test_run_and_exit_oneshot_prints_system_exit_message( "hermes_cli.oneshot", types.SimpleNamespace(run_oneshot=fake_run_oneshot), ) + monkeypatch.setattr(main_mod, "_cleanup_oneshot_runtime", lambda: None) monkeypatch.setattr(main_mod, "_exit_after_oneshot", lambda rc: exits.append(rc)) main_mod._run_and_exit_oneshot("hello") @@ -986,6 +988,7 @@ def test_run_and_exit_oneshot_routes_keyboard_interrupt_to_130( "hermes_cli.oneshot", types.SimpleNamespace(run_oneshot=fake_run_oneshot), ) + monkeypatch.setattr(main_mod, "_cleanup_oneshot_runtime", lambda: None) monkeypatch.setattr(main_mod, "_exit_after_oneshot", lambda rc: exits.append(rc)) main_mod._run_and_exit_oneshot("hello")