Skip to content

Commit 5c9083e

Browse files
committed
Fix PureWindowsPath separators for Pythons >= 3.12
Fixes #1006
1 parent 0a4593d commit 5c9083e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pyfakefs/fake_pathlib.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ def init_module(filesystem):
6060
else:
6161
# in Python 3.12, the flavour is no longer an own class,
6262
# but points to the os-specific path module (posixpath/ntpath)
63-
fake_os = FakeOsModule(filesystem)
64-
fake_path = fake_os.path
65-
FakePathlibModule.PureWindowsPath._flavour = fake_path
66-
FakePathlibModule.PurePosixPath._flavour = fake_path
63+
fake_posix_os = FakeOsModule(filesystem)
64+
fake_posix_path = fake_posix_os.path
65+
FakePathlibModule.PurePosixPath._flavour = fake_posix_path
66+
# The Windows path separators must be customized.
67+
fake_nt_os = FakeOsModule(filesystem)
68+
fake_nt_path = fake_nt_os.path
69+
fake_nt_path.sep = "\\"
70+
fake_nt_path.altsep = "/"
71+
FakePathlibModule.PureWindowsPath._flavour = fake_nt_path
6772

6873

6974
def _wrap_strfunc(strfunc):

0 commit comments

Comments
 (0)