From 1965fde3940f2a0ed02ecefa3419dd8daab24a8f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:36:37 -0700 Subject: [PATCH] test: update Windows shell-hook flag test for the Popen-based spawn _spawn() now uses subprocess.Popen + communicate() instead of subprocess.run(); the windows_only creationflags assertion mocks Popen accordingly and additionally pins that the POSIX-only process_group kwarg never reaches a Windows spawn. --- tests/test_windows_subprocess_no_window_flags.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_windows_subprocess_no_window_flags.py b/tests/test_windows_subprocess_no_window_flags.py index a3d67af7df..4855072cc3 100644 --- a/tests/test_windows_subprocess_no_window_flags.py +++ b/tests/test_windows_subprocess_no_window_flags.py @@ -165,12 +165,18 @@ def test_shell_hooks_hide_hook_command_windows(monkeypatch): captured = [] - def fake_run(cmd, **kwargs): + class FakeProc: + returncode = 0 + + def communicate(self, input=None, timeout=None): + return "{}", "" + + def fake_popen(cmd, **kwargs): captured.append((cmd, kwargs)) - return SimpleNamespace(returncode=0, stdout="{}", stderr="") + return FakeProc() monkeypatch.setattr(shell_hooks, "windows_hide_flags", lambda: _CREATE_NO_WINDOW) - monkeypatch.setattr(shell_hooks.subprocess, "run", fake_run) + monkeypatch.setattr(shell_hooks.subprocess, "Popen", fake_popen) result = shell_hooks._spawn( shell_hooks.ShellHookSpec(event="post_tool_call", command="hook-bin --flag"), @@ -179,6 +185,8 @@ def test_shell_hooks_hide_hook_command_windows(monkeypatch): assert result["returncode"] == 0 assert captured[0][1]["creationflags"] == _CREATE_NO_WINDOW + # The POSIX-only process_group kwarg must NOT reach a Windows spawn. + assert "process_group" not in captured[0][1]