test: make the suite pass on Windows#596
Open
SHudici wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 refusesPath.unlink()in teardown whileGraphStore(or the fixture itself) still holds the file open. POSIX allows unlinking open files, so CI never sees this.tests/test_skills.pywrote through the realPath.home()and asserted POSIX exec bits, which fails on Windows runners.os.killprobing, executable-bit checks) that cannot pass on Windows by design.Fix
Test-only changes across 11 files:
NamedTemporaryFilehandle immediately after creation (the file persists thanks todelete=False;GraphStorereopens it by path). 23 sites.Path.home()intest_skills.pyinstead of touching the real home directory, and restorestore.closeviapatch.objectintest_changes.pyso teardown always runs against the real method.@pytest.mark.skipif(os.name != "posix")on the two POSIX-only tests, with reasons.Testing
🤖 Generated with Claude Code