diff options
| author | Barney Gale <barney.gale@gmail.com> | 2023-12-28 22:44:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-28 22:44:29 (GMT) |
| commit | 6ca0e6754eedf4c9cf48794fa6c27281668b8d7c (patch) | |
| tree | 8e7205577ae694235aea0e0966ddd9b8811580b4 /Lib/test/test_pathlib/test_pathlib.py | |
| parent | b664d9159964f0609d50dabd02f71af0227d8718 (diff) | |
| download | cpython-6ca0e6754eedf4c9cf48794fa6c27281668b8d7c.zip cpython-6ca0e6754eedf4c9cf48794fa6c27281668b8d7c.tar.gz cpython-6ca0e6754eedf4c9cf48794fa6c27281668b8d7c.tar.bz2 | |
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.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
| -rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index db5f3b2..8f95c80 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -15,6 +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 os_helper from test.support.os_helper import TESTFN, FakePath from test.test_pathlib import test_pathlib_abc @@ -1660,6 +1661,48 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): self.assertEqual(next(it), expected) path = path / 'd' + def test_walk_above_recursion_limit(self): + recursion_limit = 40 + # directory_depth > recursion_limit + directory_depth = recursion_limit + 10 + base = self.cls(self.base, 'deep') + path = base.joinpath(*(['d'] * directory_depth)) + path.mkdir(parents=True) + + with set_recursion_limit(recursion_limit): + list(base.walk()) + list(base.walk(top_down=False)) + + def test_glob_many_open_files(self): + depth = 30 + P = self.cls + p = base = P(self.base) / 'deep' + p.mkdir() + for _ in range(depth): + p /= 'd' + p.mkdir() + pattern = '/'.join(['*'] * depth) + iters = [base.glob(pattern) for j in range(100)] + for it in iters: + self.assertEqual(next(it), p) + iters = [base.rglob('d') for j in range(100)] + p = base + for i in range(depth): + p = p / 'd' + for it in iters: + self.assertEqual(next(it), p) + + def test_glob_above_recursion_limit(self): + recursion_limit = 50 + # directory_depth > recursion_limit + directory_depth = recursion_limit + 10 + base = self.cls(self.base, 'deep') + path = base.joinpath(*(['d'] * directory_depth)) + path.mkdir(parents=True) + + with set_recursion_limit(recursion_limit): + list(base.glob('**/')) + @only_posix class PosixPathTest(PathTest, PurePosixPathTest): |
