Skip to content

Fix Windows drive-relative Path.resolve(strict=False) - #1353

Open
maqsudovelnur-creator wants to merge 1 commit into
pytest-dev:mainfrom
maqsudovelnur-creator:fix-1324-drive-relative-resolve
Open

maqsudovelnur-creator wants to merge 1 commit into
pytest-dev:mainfrom
maqsudovelnur-creator:fix-1324-drive-relative-resolve

Conversation

@maqsudovelnur-creator

Copy link
Copy Markdown

Describe the changes

Fixes #1324.

On Windows, with the current directory set to C:\test, resolving
c:test\test_data/dummy1.xml with strict=False returned
c:\est\test_data\dummy1.xml instead of
C:\test\test\test_data\dummy1.xml.

_join_real_path treated a drive prefix as an absolute root and discarded the
first character of the relative component. For drive-relative paths on the
current drive, use the current directory, comparing drive letters without case
sensitivity, and retain the complete relative component. Preserve the existing
root handling for absolute paths and paths on another drive.

Add two regression tests to the existing pathlib test class, covering existing
and missing files, both drive-letter cases, and mixed separators. The inherited
real-filesystem variants also pass on native Windows. Add a release-note entry
under Unreleased / Fixes.

Validation

Windows, Python 3.13:

  • Both integrated regression tests fail without the fix and pass with it.
  • Native Windows filesystem variants: 2 passed with TEST_REAL_FS=1.
  • Pathlib module: 183 passed, 190 skipped.
  • Full pytest suite: 1 failed, 1286 passed, 1157 skipped, 2 xfailed, 2 xpassed.
    The sole failure is the pre-existing
    FakePathModuleTest::test_realpath_allow_missing, with the same failure message.
    No existing test gains a failure, skip, or xfail. Two new skips are the normally
    disabled real-filesystem variants of the new tests.
  • The production patch was independently verified in a fresh GitHub clone and
    new virtual environment before integrating these tests.
  • Pyupgrade, Ruff lint/format, blacken-docs, whitespace/EOF, debug-statements,
    autoflake, and mypy hooks pass using Python 3.13 through a separate local
    configuration; the tracked configuration is unchanged. Codespell could not
    run due to Windows application control (WinError 4551), so its result is pending.
  • git diff --check passes.

This change covers strict=False as reported in #1324. A separate drive-relative
validation problem with strict=True is outside this fix. Other Python versions
and platforms remain for CI validation.

Tasks

  • Unit tests added that reproduce the issue
  • Fix added
  • Entry to release notes added
  • Pre-commit CI shows no errors (pending)
  • Unit tests passing in CI (pending; local results above)
  • Documentation preview: not applicable

This branch has not been deployed

No deployments
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.

Windows drive-relative pathlib.Path.resolve(strict=False) resolves incorrectly in pyfakefs 6.2.0

1 participant