Skip to content

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

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

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

@qzyu999qzyu999 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

CategoryFilesFix
MAX_PATH (260 chars)conftest.pyRANDOM_LENGTH = 8 (was 20)
SQLite URI formatconftest.py, test_sql.pywarehouse.as_posix() in URI construction
File locking (WinError 32)test_io.py, test_pyarrow.pyClose file handles before temp cleanup
Path assertionstest_pyarrow.pyos.path.abspath() instead of hardcoded paths
File URI formattest_pyarrow.pyRaw paths instead of file:{tmpdir}
Rich box renderingtest_pyarrow.pyContent assertions instead of exact formatting
Error message formattest_pyarrow.pyRelaxed match ([WinError 2] vs [Errno 2])
Path separatorstest_hive.pyNormalize backslashes in assertions
Kerberos unavailabletest_hive.pyskipif(sys.platform == 'win32')
Temp dir cleanuptest_manifest.pyignore_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

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

@FokkoFokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to run the tests in Windows against the CI?

nullable=True,
),
)
expected = """Mismatch in fields:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look unrelated

@qzyu999

Copy link
Copy Markdown
ContributorAuthor

Closing, these test fixes have been folded into #3723 per review feedback (makes more sense to bundle with the Windows CI job).

@qzyu999qzyu999 closed this Aug 2, 2026
Fokko pushed a commit that referenced this pull request Aug 4, 2026
## Rationale
Adds `windows-latest` to the Python CI workflow, enabling automated
testing on Windows.
**Merge order**: #3721 must merge first (library fix for drive letter
parsing). This PR is branched on top of it.
**Supersedes**: #3722 (test fixes are now here instead of separate).
Depends on:
- #3721 (IO: Fix Windows drive letters misidentified as URI schemes)
- #3722 (Tests: Fix Windows compatibility in unit test suite)
## Changes
- Add `windows-unit-test` job (Python 3.12, `windows-latest`)
- Fix test platform assumptions (MAX_PATH, file locking, path formats,
SQLite URIs)
- Skip Kerberos tests on Windows (C lib unavailable)
- Skip Rich box-rendering tests on Windows (terminal-dependent
formatting)
## Expected result
Locally verified: 3801 passed, 1 skipped, 0 failures on Windows.
Depends on #3721. Closes#2477.
@qzyu999

Copy link
Copy Markdown
ContributorAuthor

This is completed as of #3723

Sign up for freeto 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.

2 participants

@qzyu999@Fokko