Skip to content

Commit 2339e7c

Browse files
authored
gh-116057: Use relative recursion limits when testing os.walk() and Path.walk() (#116058)
Replace test.support.set_recursion_limit with test.support.infinite_recursion.
1 parent c5fa796 commit 2339e7c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/test/test_os.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from test.support import import_helper
3535
from test.support import os_helper
3636
from test.support import socket_helper
37-
from test.support import set_recursion_limit
37+
from test.support import infinite_recursion
3838
from test.support import warnings_helper
3939
from platform import win32_is_iot
4040

@@ -1496,7 +1496,7 @@ def test_walk_many_open_files(self):
14961496
def test_walk_above_recursion_limit(self):
14971497
depth = 50
14981498
os.makedirs(os.path.join(self.walk_path, *(['d'] * depth)))
1499-
with set_recursion_limit(depth - 5):
1499+
with infinite_recursion(depth - 5):
15001500
all = list(self.walk(self.walk_path))
15011501

15021502
sub2_path = self.sub2_tree[0]

Lib/test/test_pathlib/test_pathlib.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from test.support import import_helper
1717
from test.support import is_emscripten, is_wasi
18-
from test.support import set_recursion_limit
18+
from test.support import infinite_recursion
1919
from test.support import os_helper
2020
from test.support.os_helper import TESTFN, FakePath
2121
from test.test_pathlib import test_pathlib_abc
@@ -1199,7 +1199,7 @@ def test_walk_above_recursion_limit(self):
11991199
path = base.joinpath(*(['d'] * directory_depth))
12001200
path.mkdir(parents=True)
12011201

1202-
with set_recursion_limit(recursion_limit):
1202+
with infinite_recursion(recursion_limit):
12031203
list(base.walk())
12041204
list(base.walk(top_down=False))
12051205

@@ -1239,7 +1239,7 @@ def test_glob_above_recursion_limit(self):
12391239
path = base.joinpath(*(['d'] * directory_depth))
12401240
path.mkdir(parents=True)
12411241

1242-
with set_recursion_limit(recursion_limit):
1242+
with infinite_recursion(recursion_limit):
12431243
list(base.glob('**/'))
12441244

12451245
def test_glob_pathlike(self):

0 commit comments

Comments
 (0)