test(desktop): neutralize the Linux desktop-entry install in the Ctrl-C exit test

Patching hermes_cli.main.subprocess.run swaps the shared stdlib module's
attribute, so every subprocess.run in the process raises. On Linux the
best-effort desktop-entry install runs refresh_desktop_databases via
subprocess.run BEFORE the attached launch — outside the KeyboardInterrupt
handler under test — so the mock's interrupt aborted the whole pytest
process (CI: 'tests/hermes_cli/test_gui_command.py:1070:
KeyboardInterrupt'). Neutralize _register_linux_desktop_entry the way the
other foreground tests in this file do.
This commit is contained in:
Hermes Agent
2026-09-25 17:26:18 -05:00
committed by brooklyn!
parent 701a7559d3
commit 3f2c24d41f

View File

@@ -1125,6 +1125,12 @@ def test_gui_foreground_launch_ctrl_c_exits_cleanly(tmp_path, monkeypatch, capsy
"""
root = _make_desktop_tree(tmp_path)
monkeypatch.setattr(cli_main, "PROJECT_ROOT", root)
# Patching hermes_cli.main.subprocess.run swaps the shared stdlib module's
# attribute, so EVERY subprocess.run in the process raises. On Linux the
# best-effort desktop-entry install runs refresh_desktop_databases →
# subprocess.run BEFORE the attached launch — outside the KeyboardInterrupt
# handler under test — so neutralize it like the other foreground tests do.
monkeypatch.setattr(main_desktop, "_register_linux_desktop_entry", lambda **kw: None)
packaged_exe = _make_packaged_executable(root, monkeypatch)
ok = subprocess.CompletedProcess([], 0)