8000 GH-113528: Remove a couple of expensive pathlib ABC tests (#113534) · python/cpython@6ca0e67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ca0e67

Browse files
authored
GH-113528: Remove a couple of expensive pathlib ABC tests (#113534)
Run expensive tests for walking and globbing from `test_pathlib` but not `test_pathlib_abc`. The ABCs are not as tightly optimised as the classes in top-level `pathlib`, and so these tests are taking rather a long time on some buildbots. Coverage of the main `pathlib` classes should suffice.
1 parent b664d91 commit 6ca0e67

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +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
1819
from test.support import os_helper
1920
from test.support.os_helper import TESTFN, FakePath
2021
from test.test_pathlib import test_pathlib_abc
@@ -1660,6 +1661,48 @@ def test_walk_many_open_files(self):
16601661
self.assertEqual(next(it), expected)
16611662
path = path / 'd'
16621663

1664+
def test_walk_above_recursion_limit(self):
1665+
recursion_limit = 40
1666+
# directory_depth > recursion_limit
1667+
directory_depth = recursion_limit + 10
1668+
base = self.cls(self.base, 'deep')
1669+
path = base.joinpath(*(['d'] * directory_depth))
1670+
path.mkdir(parents=True)
1671+
1672+
with set_recursion_limit(recursion_limit):
1673+
list(base.walk())
1674+
list(base.walk(top_down=False))
1675+
1676+
def test_glob_many_open_files(self):
1677+
depth = 30
1678+
P = self.cls
1679+
p = base = P(self.base) / 'deep'
1680+
p.mkdir()
1681+
for _ in range(depth):
1682+
p /= 'd'
1683+
p.mkdir()
1684+
pattern = '/'.join(['*'] * depth)
1685+
iters = [base.glob(pattern) for j in range(100)]
1686+
for it in iters:
1687+
self.assertEqual(next(it), p)
1688+
iters = [base.rglob('d') for j in range(100)]
1689+
p = base
1690+
for i in range(depth):
1691+
p = p / 'd'
1692+
for it in iters:
1693+
self.assertEqual(next(it), p)
1694+
1695+
def test_glob_above_recursion_limit(self):
1696+
recursion_limit = 50
1697+
# directory_depth > recursion_limit
1698+
directory_depth = recursion_limit + 10
1699+
base = self.cls(self.base, 'deep')
1700+
path = base.joinpath(*(['d'] * directory_depth))
1701+
path.mkdir(parents=True)
1702+
1703+
with set_recursion_limit(recursion_limit):
1704+
list(base.glob('**/'))
1705+
16631706

16641707
@only_posix
16651708
class PosixPathTest(PathTest, PurePosixPathTest):

Lib/test/test_pathlib/test_pathlib_abc.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase
99
import posixpath
1010

11-
from test.support import set_recursion_limit
1211
from test.support.os_helper import TESTFN
1312

1413

@@ -1224,25 +1223,6 @@ def test_rglob_symlink_loop(self):
12241223
}
12251224
self.assertEqual(given, {p / x for x in expect})
12261225

1227-
def test_glob_many_open_files(self):
1228-
depth = 30
1229-
P = self.cls
1230-
p = base = P(self.base) / 'deep'
1231-
p.mkdir()
1232-
for _ in range(depth):
1233-
p /= 'd'
1234-
p.mkdir()
1235-
pattern = '/'.join(['*'] * depth)
1236-
iters = [base.glob(pattern) for j in range(100)]
1237-
for it in iters:
1238-
self.assertEqual(next(it), p)
1239-
iters = [base.rglob('d') for j in range(100)]
1240-
p = base
1241-
for i in range(depth):
1242-
p = p / 'd'
1243-
for it in iters:
1244-
self.assertEqual(next(it), p)
1245-
12461226
def test_glob_dotdot(self):
12471227
# ".." is not special in globs.
12481228
P = self.cls
@@ -1286,17 +1266,6 @@ def test_glob_long_symlink(self):
12861266
bad_link.symlink_to("bad" * 200)
12871267
self.assertEqual(sorted(base.glob('**/*')), [bad_link])
12881268

1289-
def test_glob_above_recursion_limit(self):
1290-
recursion_limit = 50
1291-
# directory_depth > recursion_limit
1292-
directory_depth = recursion_limit + 10
1293-
base = self.cls(self.base, 'deep')
1294-
path = base.joinpath(*(['d'] * directory_depth))
1295-
path.mkdir(parents=True)
1296-
1297-
with set_recursion_limit(recursion_limit):
1298-
list(base.glob('**/'))
1299-
13001269
def test_glob_recursive_no_trailing_slash(self):
13011270
P = self.cls
13021271
p = P(self.base)
@@ -1825,17 +1794,6 @@ def test_walk_symlink_location(self):
18251794
else:
18261795
self.fail("symlink not found")
18271796

1828-
def test_walk_above_recursion_limit(self):
1829-
recursion_limit = 40
1830-
# directory_depth > recursion_limit
1831-
directory_depth = recursion_limit + 10
1832-
base = self.cls(self.base, 'deep')
1833-
path = base.joinpath(*(['d'] * directory_depth))
1834-
path.mkdir(parents=True)
1835-
1836-
with set_recursion_limit(recursion_limit):
1837-
list(base.walk())
1838-
list(base.walk(top_down=False))
18391797

18401798
class DummyPathWithSymlinks(DummyPath):
18411799
def readlink(self):

0 commit comments

Comments
 (0)
0