Skip to content

test: make the suite pass on Windows#596

Open
SHudici wants to merge 1 commit into
tirth8205:mainfrom
SHudici:fix/windows-test-teardown
Open

test: make the suite pass on Windows#596
SHudici wants to merge 1 commit into
tirth8205:mainfrom
SHudici:fix/windows-test-teardown

Conversation

@SHudici

@SHudici SHudici commented Jul 3, 2026

Copy link
Copy Markdown

Problem

On Windows the test suite reports over 200 teardown errors and several failures that have nothing to do with the code under test:

  • tempfile.NamedTemporaryFile(delete=False) keeps the OS handle open; Windows then refuses Path.unlink() in teardown while GraphStore (or the fixture itself) still holds the file open. POSIX allows unlinking open files, so CI never sees this.
  • tests/test_skills.py wrote through the real Path.home() and asserted POSIX exec bits, which fails on Windows runners.
  • Two tests exercise POSIX-only branches (os.kill probing, executable-bit checks) that cannot pass on Windows by design.

Fix

Test-only changes across 11 files:

  • Close the NamedTemporaryFile handle immediately after creation (the file persists thanks to delete=False; GraphStore reopens it by path). 23 sites.
  • Patch Path.home() in test_skills.py instead of touching the real home directory, and restore store.close via patch.object in test_changes.py so teardown always runs against the real method.
  • @pytest.mark.skipif(os.name != "posix") on the two POSIX-only tests, with reasons.

Testing

  • Windows 11 (Python 3.12): suite goes from ~228 teardown errors to 0. Combined with the two Windows product fixes in this series (TOML escaping, PID liveness), the full suite is 1412 passed / 0 failed / 0 errors.
  • POSIX behavior unchanged: closing the handle early is a no-op for the assertions, and the skipped tests still run on Linux/macOS CI.

🤖 Generated with Claude Code

Three Windows-only failure classes, 234 tests total:

- NamedTemporaryFile(delete=False) keeps an OS handle open, and Windows
  cannot unlink an open file, so every teardown unlink died with
  WinError 32 (227 teardown errors). Close the handle right after
  creation; only the generated name is used.
- The detect_changes tool tests disabled store.close() by assigning a
  lambda on the instance, which also disabled the real close in
  teardown. Use patch.object so close() is restored after the block.
- The codex-hooks tests redirected HOME, which Path.home() ignores on
  Windows since Python 3.8 — the tests were writing into the real
  ~/.codex of whoever ran them. Patch code_review_graph.skills.Path.home
  the same way the cursor-hooks tests already do.

Also add POSIX skipif markers to the two tests that assert os.kill
mock calls and unix exec bits, matching their sibling tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant