Skip to content

Commit 7ff66a1

Browse files
committed
Tests: Fix PathMock Windows compatibility on Posix in Python 3.13+
python/cpython@c6c5665 Fixes #2671
1 parent 3e9d7ac commit 7ff66a1

File tree

1 file changed

+5
-1
lines changed
  • tests/unit/create/via_global_ref/builtin/testing

1 file changed

+5
-1
lines changed

tests/unit/create/via_global_ref/builtin/testing/path.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ class PathMockABC(FakeDataABC, Path):
4747
"""Mocks the behavior of `Path`"""
4848

4949
_flavour = getattr(Path(), "_flavour", None)
50-
5150
if hasattr(_flavour, "altsep"):
5251
# Allows to pass some tests for Windows via PosixPath.
5352
_flavour.altsep = _flavour.altsep or "\\"
5453

54+
# Python 3.13 renamed _flavour to pathmod
55+
pathmod = getattr(Path(), "pathmod", None)
56+
if hasattr(pathmod, "altsep"):
57+
pathmod.altsep = pathmod.altsep or "\\"
58+
5559
def exists(self):
5660
return self.is_file() or self.is_dir()
5761

0 commit comments

Comments
 (0)