Skip to content

Tests: Fix Windows compatibility in unit test suite - #3722

Open
qzyu999 wants to merge 2 commits into
apache:mainfrom
qzyu999:fix-windows-test-compat-v2
Open

Tests: Fix Windows compatibility in unit test suite#3722
qzyu999 wants to merge 2 commits into
apache:mainfrom
qzyu999:fix-windows-test-compat-v2

Conversation

@qzyu999

@qzyu999 qzyu999 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Rationale

Prerequisite for #2477. Makes make test pass 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

3803 passed, 3 skipped, 0 failures, 0 errors (Windows, Python 3.12)

Changes

Category Files Fix
MAX_PATH (260 chars) conftest.py RANDOM_LENGTH = 8 (was 20)
SQLite URI format conftest.py, test_sql.py warehouse.as_posix() in URI construction
File locking (WinError 32) test_io.py, test_pyarrow.py Close file handles before temp cleanup
Path assertions test_pyarrow.py os.path.abspath() instead of hardcoded paths
File URI format test_pyarrow.py Raw paths instead of file:{tmpdir}
Rich box rendering test_pyarrow.py Content assertions instead of exact formatting
Error message format test_pyarrow.py Relaxed match ([WinError 2] vs [Errno 2])
Path separators test_hive.py Normalize backslashes in assertions
Kerberos unavailable test_hive.py skipif(sys.platform == 'win32')
Temp dir cleanup test_manifest.py ignore_cleanup_errors=True

Are these changes tested?

Yes full make test equivalent run locally on Windows: 3803 passed.
All changes are backwards-compatible on Linux (assertions use platform-aware values, skipif only fires on Windows, as_posix() is a no-op on POSIX).

Are there any user-facing changes?

No. Test-only changes.

Related: #2477

qzyu999 added 2 commits July 29, 2026 14:57
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
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