Fix cross-platform test fixture failures on Windows - #1707
Open
hardikkaurani wants to merge 2 commits into
Open
hardikkaurani wants to merge 2 commits into
hardikkaurani wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes are test-only and correctly replace POSIX-specific commands with cross-platform Python equivalents, with only a minor cleanup nit noted.
Pull request overview
This PR updates test fixtures to be cross-platform (especially Windows) by removing reliance on POSIX cp/rm shell commands and using Python’s standard library for filesystem setup/cleanup.
Changes:
- Replaced
subprocess.call(['cp', '-r', ...])withshutil.copytree()in test module setup to copytest/raw_datainto the expectedraw_datalocation. - Replaced
subprocess.call(['rm', '-r', ...])withshutil.rmtree()/os.remove()in teardown and related cleanup paths. - Added pre-cleaning of destination paths to keep compatibility with Python versions that don’t support
dirs_exist_ok.
File summaries
| File | Description |
|---|---|
| test/test_retriever.py | Switches fixture setup/teardown and test cleanup from POSIX shell commands to shutil/os operations for Windows compatibility. |
| test/test_regression.py | Applies the same cross-platform filesystem changes to regression test setup/teardown and SQLite cleanup. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
5
to
6
| import shutil | ||
| import subprocess |
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.
Description
This PR resolves cross-platform test fixture failures on Windows by replacing POSIX-specific shell commands with Python standard library operations.
Problem
In
test/test_retriever.pyandtest/test_regression.py, test setup and teardown fixtures (setup_module,teardown_module, andtest_setup_functions) invoked POSIX-specific commands viasubprocess.call(['cp', '-r', ...])andsubprocess.call(['rm', '-r', ...]).On Windows systems where POSIX binaries are not natively available in
PATH, this resulted inFileNotFoundError: [WinError 2] The system cannot find the file specified, causing all tests in these modules to fail during fixture initialization.Proposed Changes
subprocess.call(['cp', '-r', ...])withshutil.copytree()intest/test_retriever.pyandtest/test_regression.py.subprocess.call(['rm', '-r', ...])withshutil.rmtree()andos.remove()for directory and file cleanups.dirs_exist_okkeyword argument.Verification
pytest test/test_retriever.pyon Windows with Python 3.11.9: fixture setup and teardown executed successfully withoutFileNotFoundError.pytest test/test_regression.pyon Windows: fixture setup, teardown, and SQLite/CSV regression tests completed successfully.git diff --checkreports no whitespace or formatting regressions.