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).
This commit is contained in:
kshitijk4poor 2026-07-20 12:53:57 +05:30 committed by kshitij
parent 97fc8a4a3c
commit 244dabbd9c
2 changed files with 3 additions and 1 deletions

View file

@ -82,7 +82,6 @@ def _exit_after_oneshot(rc: object) -> None:
except Exception:
pass
try:
import logging
logging.shutdown()
except Exception:
pass

View file

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