From 3cf7347413e72d75fa960f0536b406da516a3796 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 4 Oct 2026 16:09:05 -0400 Subject: [PATCH] test(starlark): fake only the editor launch, not every Popen in the request TestPixletEditorHostDefaultsButDoesNotOverride patched subprocess.Popen for the whole request. When the captive-portal before_request hook's 30s AP-mode cache had expired, its `systemctl is-active hostapd` check went through subprocess.run, got the fake process, and raised TypeError (run() uses the process as a context manager): a 500 instead of 200. Seen on the Python 3.13 job; reproduced locally by forcing the cache to expire. Other calls now reach the real Popen. Co-Authored-By: Claude Opus 5.5 --- test/web_interface/test_starlark_pixlet_routes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/web_interface/test_starlark_pixlet_routes.py b/test/web_interface/test_starlark_pixlet_routes.py index 43aaa06e..4e97eb4e 100644 --- a/test/web_interface/test_starlark_pixlet_routes.py +++ b/test/web_interface/test_starlark_pixlet_routes.py @@ -1131,9 +1131,17 @@ class TestPixletEditorHostDefaultsButDoesNotOverride: class FakeProcess: pid = 424242 + real_popen = mod.subprocess.Popen + def fake_popen(cmd, *args, env=None, **kwargs): - if env is not None: - captured['env'] = env + # Only the editor launch is faked. Patching subprocess.Popen + # patches it for the whole request, and the captive-portal + # before_request hook runs `systemctl is-active hostapd` through + # subprocess.run whenever its 30s cache has expired -- which + # needs a real process (run() uses it as a context manager). + if str(script) not in cmd: + return real_popen(cmd, *args, env=env, **kwargs) + captured['env'] = env return FakeProcess() with patch.object(mod, '_validate_starlark_app_path',