test(desktop): neutralize the Linux password-store D-Bus probe in the Ctrl-C exit test
The CI Linux job aborted mid-file with a session-wide KeyboardInterrupt: the test patches hermes_cli.main.subprocess.run for the WHOLE process, and _desktop_launch_env -> _detect_linux_password_store probes org.freedesktop.secrets via dbus-send BEFORE the launch (a bare runner has no KDE/GNOME session vars). contextlib.suppress(Exception) cannot swallow KeyboardInterrupt (BaseException), so it escaped cmd_gui and pytest treated it as a user Ctrl-C, killing the rest of the file — '31 passed, 13 skipped' then non-zero exit. Neutralize _detect_linux_password_store the way the other foreground tests do; the macOS job never hit this because the probe is behind sys.platform == 'linux'.
This commit is contained in:
@@ -1126,12 +1126,15 @@ 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. Two best-effort
|
||||
# pre-launch paths call it BEFORE the attached launch — outside the
|
||||
# KeyboardInterrupt handler under test — so neutralize both the way the
|
||||
# other foreground tests do: the Linux desktop-entry install (its
|
||||
# refresh_desktop_databases probe) and the sandbox fixup's `unshare`
|
||||
# user-namespace probe.
|
||||
# attribute, so EVERY subprocess.run in the process raises. Three
|
||||
# best-effort pre-launch paths call it BEFORE the attached launch — outside
|
||||
# the KeyboardInterrupt handler under test — so neutralize each the way the
|
||||
# other foreground tests do: the Linux password-store detection (its
|
||||
# org.freedesktop.secrets D-Bus ping — contextlib.suppress(Exception)
|
||||
# cannot swallow the KeyboardInterrupt, which then aborts the whole pytest
|
||||
# session), the Linux desktop-entry install (its refresh_desktop_databases
|
||||
# probe) and the sandbox fixup's `unshare` user-namespace probe.
|
||||
monkeypatch.setattr(main_desktop, "_detect_linux_password_store", lambda: None)
|
||||
monkeypatch.setattr(main_desktop, "_register_linux_desktop_entry", lambda **kw: None)
|
||||
monkeypatch.setattr(main_desktop, "_desktop_linux_userns_sandbox_available", lambda: True)
|
||||
packaged_exe = _make_packaged_executable(root, monkeypatch)
|
||||
|
||||
Reference in New Issue
Block a user