pytest-dev / pyfakefs

Provides a fake file system that mocks the Python file system modules.
https://pytest-pyfakefs.readthedocs.io
Apache License 2.0
627 stars 88 forks source link

Fix pure windows path behavior #1011

Closed kurtmckee closed 1 month ago

kurtmckee commented 2 months ago

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

mrbean-bremen commented 1 month ago

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.

kurtmckee commented 1 month ago

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!