Skip to content

The agent that grows with you

fix(tests): accept the _kb._IS_WINDOWS guard in the kanban waitpid source-text test

teknium102429bc48a9f
diff --git a/tests/tools/test_windows_native_support.py b/tests/tools/test_windows_native_support.py
index b41a462764a..c813211d08e 100644
--- a/tests/tools/test_windows_native_support.py
+++ b/tests/tools/test_windows_native_support.py
@@ -547,7 +547,8 @@ class TestTuiGatewayEntrySignalGuards:
class TestKanbanWaitpidWindowsGuard:
"""os.WNOHANG doesn't exist on Windows — the dispatcher tick reap loop
- must be gated behind ``os.name != "nt"``."""
+ must be gated behind a Windows check (``os.name != "nt"`` or the
+ monkeypatchable ``_kb._IS_WINDOWS`` flag from ``kanban_db``)."""
def test_source_gates_waitpid_loop(self):
root = Path(__file__).resolve().parents[2]
@@ -555,20 +556,25 @@ class TestKanbanWaitpidWindowsGuard:
# Find the waitpid call and confirm it's inside a POSIX gate.
idx = source.find("os.waitpid(-1, os.WNOHANG)")
assert idx > 0, "waitpid call must exist"
- # Look backwards up to 400 chars for the gate. Accept either form:
- # `if os.name != "nt":` (run iff POSIX), or
- # `if os.name == "nt": return []` (early-return guard).
- # Both correctly keep the waitpid loop off Windows; the early-return
- # form is stronger because the rest of the function never runs.
- preamble = source[max(0, idx - 400):idx]
+ # Look backwards up to 600 chars for the gate (the Windows branch
+ # that polls Popen handles sits between the guard and the waitpid
+ # loop). Accept any of:
+ # `if os.name != "nt":` (run iff POSIX),
+ # `if os.name == "nt": return []` (early-return guard), or
+ # `if _kb._IS_WINDOWS: ... return reaped` (early-return via the
+ # kanban_db flag, which tests flip instead of faking sys.platform).
+ # All keep the waitpid loop off Windows; the early-return forms are
+ # stronger because the rest of the function never runs.
+ preamble = source[max(0, idx - 600):idx]
guard_patterns = (
'os.name != "nt"',
"os.name != 'nt'",
'os.name == "nt"', # early-return guard
"os.name == 'nt'",
+ "_kb._IS_WINDOWS", # early-return guard via kanban_db flag
)
assert any(p in preamble for p in guard_patterns), (
- "os.waitpid(-1, os.WNOHANG) must sit behind an os.name guard "
+ "os.waitpid(-1, os.WNOHANG) must sit behind a Windows guard "
f"(checked patterns: {guard_patterns})"
)