Skip to content

gh-116057: Use relative recursion limits when testing os.walk and Path.walk #116058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from test.support import import_helper
from test.support import os_helper
from test.support import socket_helper
from test.support import set_recursion_limit
from test.support import infinite_recursion
from test.support import warnings_helper
from platform import win32_is_iot

Expand Down Expand Up @@ -1496,7 +1496,7 @@ def test_walk_many_open_files(self):
def test_walk_above_recursion_limit(self):
depth = 50
os.makedirs(os.path.join(self.walk_path, *(['d'] * depth)))
with set_recursion_limit(depth - 5):
with infinite_recursion(depth - 5):
all = list(self.walk(self.walk_path))

sub2_path = self.sub2_tree[0]
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from test.support import import_helper
from test.support import is_emscripten, is_wasi
from test.support import set_recursion_limit
from test.support import infinite_recursion
from test.support import os_helper
from test.support.os_helper import TESTFN, FakePath
from test.test_pathlib import test_pathlib_abc
Expand Down Expand Up @@ -1199,7 +1199,7 @@ def test_walk_above_recursion_limit(self):
path = base.joinpath(*(['d'] * directory_depth))
path.mkdir(parents=True)

with set_recursion_limit(recursion_limit):
with infinite_recursion(recursion_limit):
list(base.walk())
list(base.walk(top_down=False))

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

with set_recursion_limit(recursion_limit):
with infinite_recursion(recursion_limit):
list(base.glob('**/'))

def test_glob_pathlike(self):
Expand Down