Skip to content

Commit

Permalink
Tests: Fix PathMock Windows compatibility on Posix in Python 3.13+
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Nov 29, 2023
1 parent 3e9d7ac commit c241511
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/unit/create/via_global_ref/builtin/testing/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ def fake_child(self, path):
class PathMockABC(FakeDataABC, Path):
"""Mocks the behavior of `Path`"""

_flavour = getattr(Path(), "_flavour", None)
# Python 3.13 renamed _flavour to pathmod
pathmod = getattr(Path(), "pathmod", getattr(Path(), "_flavour", None))

if hasattr(_flavour, "altsep"):
if hasattr(pathmod, "altsep"):
# Allows to pass some tests for Windows via PosixPath.
_flavour.altsep = _flavour.altsep or "\\"
pathmod.altsep = pathmod.altsep or "\\"

def exists(self):
return self.is_file() or self.is_dir()
Expand Down

0 comments on commit c241511

Please sign in to comment.