Skip to content

Commit a55d3e0

Browse files
[PR #8619/d1c8dfbb backport][3.10] Fix monkey patches for pathlib changes in Python 3.13 (#8623)
Co-authored-by: Steve Repsher <[email protected]>
1 parent 06eedff commit a55d3e0

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
@@ -434,10 +434,10 @@ def mock_iterdir(self: pathlib.Path) -> Generator[pathlib.Path, None, None]:
434434
raise PermissionError()
435435
return real_iterdir(self)
436436

437-
def mock_is_dir(self: pathlib.Path) -> bool:
437+
def mock_is_dir(self: pathlib.Path, **kwargs: Any) -> bool:
438438
if my_dir.samefile(self.parent):
439439
raise PermissionError()
440-
return real_is_dir(self)
440+
return real_is_dir(self, **kwargs)
441441

442442
monkeypatch.setattr("pathlib.Path.iterdir", mock_iterdir)
443443
monkeypatch.setattr("pathlib.Path.is_dir", mock_is_dir)
@@ -554,8 +554,8 @@ async def test_access_mock_special_resource(
554554
real_result = my_special.stat()
555555
real_stat = pathlib.Path.stat
556556

557-
def mock_stat(self: pathlib.Path) -> os.stat_result:
558-
s = real_stat(self)
557+
def mock_stat(self: pathlib.Path, **kwargs: Any) -> os.stat_result:
558+
s = real_stat(self, **kwargs)
559559
if os.path.samestat(s, real_result):
560560
mock_mode = S_IFIFO | S_IMODE(s.st_mode)
561561
s = os.stat_result([mock_mode] + list(s)[1:])

0 commit comments

Comments
 (0)