Tests: Fix Windows compatibility in unit test suite - #3722
Open
qzyu999 wants to merge 2 commits into
Open
Conversation
On Windows, Python's urlparse treats paths like 'C:\Users\...' as having scheme='c', which causes 'Unrecognized filesystem type in URI: c' errors. This adds a platform-guarded predicate that detects single-character alphabetic schemes on Windows and remaps them to 'file', enabling correct local filesystem routing. Fixes all three parse sites (_infer_file_io_from_scheme, PyArrowFileIO.parse_location, FsspecFileIO._get_fs_from_uri) and includes platform-conditional tests. Related: apache#2477, apache#1005
Enable the full unit test suite to pass on Windows (3803 passed, 0 failures). Changes: - Reduce RANDOM_LENGTH from 20 to 8 to stay under Windows MAX_PATH (260 chars) - Use warehouse.as_posix() in SQLite URIs for cross-platform path formatting - Close file handles before temp directory cleanup (Windows file locking) - Use os.path.abspath() in path assertions instead of hardcoded POSIX paths - Use raw paths instead of file: URIs in pyarrow test fixtures - Relax Rich box-drawing assertions to check content not formatting - Skip Kerberos tests on Windows (puresasl C lib unavailable) - Relax error message assertion ([Errno 2] vs [WinError 2]) Depends on apache#3721. Related: apache#2477
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.
Rationale
Prerequisite for #2477. Makes
make testpass on Windows by fixing platform assumptions in test code.Depends on #3721 (IO: Fix Windows drive letters misidentified as URI schemes).
No library code changes all changes are in test files and
conftest.py.Result
Changes
conftest.pyRANDOM_LENGTH = 8(was 20)conftest.py,test_sql.pywarehouse.as_posix()in URI constructiontest_io.py,test_pyarrow.pytest_pyarrow.pyos.path.abspath()instead of hardcoded pathstest_pyarrow.pyfile:{tmpdir}test_pyarrow.pytest_pyarrow.py[WinError 2]vs[Errno 2])test_hive.pytest_hive.pyskipif(sys.platform == 'win32')test_manifest.pyignore_cleanup_errors=TrueAre these changes tested?
Yes full
make testequivalent run locally on Windows: 3803 passed.All changes are backwards-compatible on Linux (assertions use platform-aware values,
skipifonly fires on Windows,as_posix()is a no-op on POSIX).Are there any user-facing changes?
No. Test-only changes.
Related: #2477