diff --git a/tests/tools/test_windows_compat.py b/tests/tools/test_windows_compat.py index 5c7e920aae34c..478778131bfdf 100644 --- a/tests/tools/test_windows_compat.py +++ b/tests/tools/test_windows_compat.py @@ -51,17 +51,23 @@ class TestStartNewSession: @pytest.mark.parametrize("relpath", GUARDED_FILES) def test_uses_start_new_session(self, relpath): - """Each guarded file must use start_new_session=True for process isolation.""" + """Each guarded file must use start_new_session instead of preexec_fn. + + The value may be a variable (e.g. ``popen_start_new_session``) when + the spawn conditionally uses ``systemd-run --scope`` which creates its + own session/cgroup — in that case ``start_new_session=False`` is + correct and a literal ``True`` would mask scope-creation failures. + """ filepath = PROJECT_ROOT / relpath if not filepath.exists(): pytest.skip(f"{relpath} not found") source = filepath.read_text(encoding="utf-8") - # Files should use start_new_session=True, not preexec_fn + # Files should use start_new_session, not preexec_fn assert "preexec_fn" not in source, ( f"{relpath} still uses preexec_fn; use start_new_session=True instead" ) - assert "start_new_session=True" in source, ( - f"{relpath} missing start_new_session=True in Popen call" + assert "start_new_session=" in source, ( + f"{relpath} missing start_new_session= in Popen call" )