Skip to content

test(release): state the O_NOFOLLOW contract per platform - #123

Merged
abrichr merged 1 commit into
mainfrom
fix/windows-nofollow-test-contract
Aug 20, 2026
Merged

test(release): state the O_NOFOLLOW contract per platform#123
abrichr merged 1 commit into
mainfrom
fix/windows-nofollow-test-contract

Conversation

@abrichr

@abrichr abrichr commented Aug 20, 2026

Copy link
Copy Markdown
Member

Fixes the windows-latest failure on main from #122 (1511075).

What broke

test_download_verification_reads_through_the_checked_path ended with:

with pytest.raises(OSError):
    download_verifier._read_bytes(directory / "installer.bin")

That holds only where os.O_NOFOLLOW exists. Windows has neither the flag nor
an equivalent, which _no_follow_opener already documents by falling back to
0, so the open succeeds there:

FAILED tests/test_native_release.py::test_download_verification_reads_through_the_checked_path - Failed: DID NOT RAISE OSError
1 failed, 996 passed, 7 skipped

Only the test was wrong. The shipped behaviour is correct on both platforms.

What the test asserts now

The assertion that matters on every platform runs first and is unchanged:
verify() refuses a link outright, so no link ever reaches the hash loop. That
assertion passed on Windows in the failing run.

The direct-read assertion now states the real per-platform contract - refused
where O_NOFOLLOW exists, followed where it does not, with the explicit
is_symlink check as the whole defence there.

Verification

  • POSIX branch: uv run pytest tests/ -q on macOS -> 998 passed, 6 skipped.
  • Windows branch: simulated by removing os.O_NOFOLLOW and reloading the
    module. verify() still refuses the link
    (download directory contains a link or non-regular file) and _read_bytes
    reads through it, which is what the new branch asserts.
  • uv run ruff check engine/ tests/ scripts/ -> clean.

🤖 Generated with Claude Code

`test_download_verification_reads_through_the_checked_path` asserted that
reading a symbolic link directly raises OSError. That is true only where
`os.O_NOFOLLOW` exists. Windows has no such flag and no equivalent, which
`_no_follow_opener` already documents, so the open succeeds there and the
test failed on the windows-latest lane after merge.

The assertion that matters holds on every platform and now runs before the
platform split: `verify()` refuses a link outright, so no link ever reaches
the hash loop. The direct-read assertion now states the real contract for
each platform -- refused where `O_NOFOLLOW` exists, followed where it does
not, with the explicit `is_symlink` check as the defence there.

Verified both branches locally: the POSIX branch on macOS, and the Windows
branch by removing `os.O_NOFOLLOW` and reloading the module, where `verify()`
still refuses the link.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@abrichr
abrichr merged commit a735601 into main Aug 20, 2026
17 checks passed
@abrichr
abrichr deleted the fix/windows-nofollow-test-contract branch August 20, 2026 00:36
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