Skip to content

fix(tests): make the suite collect and run on Windows - #2035

Closed
Dopetaiga wants to merge 1 commit into
anthropics:mainfrom
Dopetaiga:fix/windows-test-suite
Closed

Dopetaiga wants to merge 1 commit into
anthropics:mainfrom
Dopetaiga:fix/windows-test-suite

Conversation

@Dopetaiga

Copy link
Copy Markdown

Fixes #2027

Problem

Four POSIX assumptions broke the suite on Windows, exactly as the issue lays out:

  1. skipif(os.geteuid() == 0, …) decorators evaluated at import time crash collection on Windows (os.geteuid doesn't exist) — test_file_store.py (×2) and test_delete_discipline.py.
  2. The FileStore-backed memory_sync suites mostly lacked test_file_store.py's module-level os.name != "posix" skip, so FileStore's O_NOFOLLOW RuntimeError turned into mass test failures.
  3. mock_aws_config held NamedTemporaryFile(delete=True) open while botocore re-read the file — a second open of the same file fails on Windows, surfacing as ProfileNotFound.
  4. Three symlink tests in test_agent_toolset.py lacked the @needs_symlinks marker their siblings carry.

Fix

  • Guard the decorators: os.name == "posix" and os.geteuid() == 0 (short-circuits, evaluated only on POSIX).
  • Add the same pytestmark skip to all FileStore-backed memory_sync suites — the issue counted 38 failures in two files, but the same missing marker affects the other suites in that directory too (test_e2e_memory, test_final_flush, test_folder_trust, test_keep_only_copy, test_lost_response, test_two_pass); all get the identical one-liner.
  • Rewrite the fixture to delete=False + explicit close()/os.unlink() in finally.
  • Add @needs_symlinks to the three tests.

No production code is touched; this only makes the existing suite collect and pass/skip cleanly on Windows.

Verification (native Windows 11, Python 3.12)

  • Before: pytest --collect-only → 3 errors during collection (interrupted); after: 12 821 tests collected, 0 errors
  • tests/lib/test_bedrock.py: the 4 named ProfileNotFound failures now pass — 46 passed (fixture rewritten)
  • memory_sync + file_store + agent_toolset: 0 failures — POSIX suites skip (168 skipped), the rest pass
  • One pre-existing failure remains in test_agent_toolset.py::test_write_creates_deeply_nested_missing_directories (50-deep tmp paths exceed Windows MAX_PATH; fails identically on unmodified main, unrelated to this change — happy to take it in a follow-up if wanted)
  • ruff check / ruff format --check on the touched files: clean

Four POSIX assumptions broke collection or tests on Windows (issue anthropics#2027):

- skipif decorators called os.geteuid() at import time, which does not
  exist on Windows, crashing collection of three modules; guard them
  with os.name == "posix" so they only evaluate on POSIX
- the FileStore-backed memory_sync suites carried no module-level
  non-POSIX skip (test_file_store.py has one), so 100+ tests failed on
  FileStore's O_NOFOLLOW RuntimeError; add the same pytestmark to all
  of them
- the mock_aws_config fixture kept a NamedTemporaryFile(delete=True)
  open while botocore re-read it, which Windows forbids; close and
  unlink explicitly instead
- three symlink tests in test_agent_toolset.py lacked the
  @needs_symlinks marker their siblings carry
@Dopetaiga
Dopetaiga requested a review from a team as a code owner October 25, 2026 09:09
@prasad2512

Copy link
Copy Markdown

Hi @Dopetaiga, thank you for looking into this, but PR #2028 addressing Issue #2027 was already submitted by me, thoroughly verified across Linux/Pytest, and officially approved by @chrikrah (see review).

It is currently awaiting maintainer review and merge by @dtmeadows-ant. To avoid duplicate efforts and keep the review queue clean, could you please close this duplicate PR?

@Dopetaiga

Copy link
Copy Markdown
Author

Sorry for the duplicate — I checked the issue thread and assignees before claiming but missed this PR (it doesn't surface in the issue's linked-PR sidebar). Closing mine as asked.

One piece of information that may be useful for #2028: while verifying on native Windows I found the missing non-POSIX pytestmark extends beyond the two files it lists — test_e2e_memory.py, test_final_flush.py, test_folder_trust.py, test_keep_only_copy.py, test_lost_response.py, and test_two_pass.py in tests/lib/tools/memory_sync/ are all FileStore-backed and fail the same way (FileStore requires O_NOFOLLOW support on this platform, ~60 further failures). Same one-line marker as the other files fixes all of them. Feel free to fold that in or handle it in a follow-up.

Also noted, out of scope: test_write_creates_deeply_nested_missing_directories fails on Windows even on unmodified main (50-deep tmp paths exceed MAX_PATH) — pre-existing, separate from this issue.

@Dopetaiga Dopetaiga closed this Oct 25, 2026
@prasad2512

Copy link
Copy Markdown

Thank you so much @Dopetaiga, really appreciate your understanding in closing the duplicate and for taking the time to verify on native Windows!

Also, thanks for highlighting the other FileStore-backed test suites in memory_sync/ — that's super helpful context. We'll make sure to get those covered as well. Cheers!

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.

Fix test collection and execution errors on Windows (geteuid, FileStore skip, bedrock tempfile lock)

2 participants