]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116057: Use relative recursion limits when testing os.walk() and Path.walk() ...
authorMalcolm Smith <smith@chaquo.com>
Sun, 10 Mar 2024 22:00:33 +0000 (22:00 +0000)
committerGitHub <noreply@github.com>
Sun, 10 Mar 2024 22:00:33 +0000 (23:00 +0100)
Replace test.support.set_recursion_limit with test.support.infinite_recursion.

Lib/test/test_os.py
Lib/test/test_pathlib/test_pathlib.py

index 3b2d5fccc30f3c1024e30a3f512903a24ba9bec5..ae8b405dab50fcd3f783f3a8415bce2f2260de9d 100644 (file)
@@ -34,7 +34,7 @@ from test import support
 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 @@ class WalkTests(unittest.TestCase):
     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]
index 7e44ae61a5eba7ac41bd906f62df7f252532eb65..6509c08d2273463fdd21d107241b505c819c0bd0 100644 (file)
@@ -15,7 +15,7 @@ from urllib.request import pathname2url
 
 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 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         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 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         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):