Skip to content

Commit

Permalink
Fix PureWindowsPath separators for Pythons >= 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed May 4, 2024
1 parent 0a4593d commit 5c9083e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pyfakefs/fake_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ def init_module(filesystem):
else:
# in Python 3.12, the flavour is no longer an own class,
# but points to the os-specific path module (posixpath/ntpath)
fake_os = FakeOsModule(filesystem)
fake_path = fake_os.path
FakePathlibModule.PureWindowsPath._flavour = fake_path
FakePathlibModule.PurePosixPath._flavour = fake_path
fake_posix_os = FakeOsModule(filesystem)
fake_posix_path = fake_posix_os.path
FakePathlibModule.PurePosixPath._flavour = fake_posix_path
# The Windows path separators must be customized.
fake_nt_os = FakeOsModule(filesystem)
fake_nt_path = fake_nt_os.path
fake_nt_path.sep = "\\"
fake_nt_path.altsep = "/"
FakePathlibModule.PureWindowsPath._flavour = fake_nt_path


def _wrap_strfunc(strfunc):
Expand Down

0 comments on commit 5c9083e

Please sign in to comment.