pyfakefs icon indicating copy to clipboard operation
pyfakefs copied to clipboard

Fix pure windows path behavior

Open kurtmckee opened this issue 9 months ago • 1 comments

Describe the changes

This PR fixes path separators for Windows paths.

[!NOTE]

A single regression test for #558 fails as a result of this change, and only on Python 3.12. I am uneasy touching this test because I harbor concerns that this test is enforcing behavior that might not be worthwhile to support.

Please review this work, together with this test, and let me know how to proceed. My gut is to remove the failing regression test but I didn't include that here.

Fixes #1006

Tasks

  • [x] Unit tests added that reproduce the issue or prove feature is working
  • [x] Fix or feature added
  • [ ] Entry to release notes added
  • [x] Pre-commit CI shows no errors
  • [ ] Unit tests passing
  • [ ] For documentation changes: The Read the Docs preview builds and looks as expected

kurtmckee avatar May 04 '24 14:05 kurtmckee

A single regression test for https://github.com/pytest-dev/pyfakefs/issues/558 fails as a result of this change

Yes, I agree that this was a questionable change, and as I wrote in the issue, it still does not handle all cases. Emulating another OS with pyfakefs has its shortcomings and will never be perfect, so I think this is a reasonable trade-off.

mrbean-bremen avatar May 04 '24 18:05 mrbean-bremen

Found the right path for this (no pun intended). :laughing:

The fix is to push the path separator customization up from the Pure*Path classes to their *Path equivalents, and to hard-code the Pure*Path classes path separators, which are (I think supposed to be) filesystem independent.

The test suite now passes all checks. I've added a changelog entry as well. Please let me know if anything else is needed, or should be accounted for!

kurtmckee avatar May 06 '24 16:05 kurtmckee