Skip to content

Commit d1c8dfb

Browse files
authored
Fix monkey patches for pathlib changes in Python 3.13 (#8619)
1 parent 7571eb9 commit d1c8dfb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGES/8551.contrib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed monkey patches for ``Path.stat()`` and ``Path.is_dir()`` for python 3.13 compatibility -- by :user:`steverep`.

tests/test_web_urldispatcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ def mock_iterdir(self: pathlib.Path) -> Generator[pathlib.Path, None, None]:
428428
raise PermissionError()
429429
return real_iterdir(self)
430430

431-
def mock_is_dir(self: pathlib.Path) -> bool:
431+
def mock_is_dir(self: pathlib.Path, **kwargs: Any) -> bool:
432432
if my_dir.samefile(self.parent):
433433
raise PermissionError()
434-
return real_is_dir(self)
434+
return real_is_dir(self, **kwargs)
435435

436436
monkeypatch.setattr("pathlib.Path.iterdir", mock_iterdir)
437437
monkeypatch.setattr("pathlib.Path.is_dir", mock_is_dir)
@@ -548,8 +548,8 @@ async def test_access_mock_special_resource(
548548
real_result = my_special.stat()
549549
real_stat = pathlib.Path.stat
550550

551-
def mock_stat(self: pathlib.Path) -> os.stat_result:
552-
s = real_stat(self)
551+
def mock_stat(self: pathlib.Path, **kwargs: Any) -> os.stat_result:
552+
s = real_stat(self, **kwargs)
553553
if os.path.samestat(s, real_result):
554554
mock_mode = S_IFIFO | S_IMODE(s.st_mode)
555555
s = os.stat_result([mock_mode] + list(s)[1:])

0 commit comments

Comments
 (0)