From 91273d44e1f502586312b0050db49870dfe8cfbb Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 28 Feb 2024 17:52:58 +0000 Subject: [PATCH 1/2] Use relative recursion limits when testing `os.walk` and `Path.walk` --- Lib/test/test_os.py | 4 ++-- Lib/test/test_pathlib/test_pathlib.py | 6 +++--- .../Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 2372ac4c21efd9..97222189183038 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -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 @@ -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] diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index c0dcf314da4bfc..08c1d004617de9 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -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 @@ -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)) @@ -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): diff --git a/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst b/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst new file mode 100644 index 00000000000000..44dbbcb67f5951 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst @@ -0,0 +1 @@ +Use relative recursion limits when testing ``os.walk`` and ``Path.walk``. From 98b8d3fc42af57df64df263caf95c355dac42d42 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Fri, 1 Mar 2024 15:55:07 +0000 Subject: [PATCH 2/2] Remove news entry --- .../next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst diff --git a/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst b/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst deleted file mode 100644 index 44dbbcb67f5951..00000000000000 --- a/Misc/NEWS.d/next/Tests/2024-02-28-17-48-47.gh-issue-116057.Fl-YG8.rst +++ /dev/null @@ -1 +0,0 @@ -Use relative recursion limits when testing ``os.walk`` and ``Path.walk``.