diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-12 15:54:48 +0300 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2019-09-12 13:54:48 +0100 |
commit | f9dc2ad89032201427ed5f08061c703794627ad9 (patch) | |
tree | 76f92a623714e6cb88f7dae8e4a175d2a4e00c02 /Lib/test/test_pathlib.py | |
parent | 5a4f82f457049b5b07b6fba4ca42bc1ecf597976 (diff) | |
download | cpython-f9dc2ad89032201427ed5f08061c703794627ad9.tar.gz cpython-f9dc2ad89032201427ed5f08061c703794627ad9.zip |
bpo-37935: Added tests for os.walk(), glob.iglob() and Path.glob() (GH-15956)
Test that they do not keep too many file descriptors open for the host OS in a reasonable test scenario.
See [bpo-37935](https://bugs.python.org/issue37935).
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index f3b385fbf36..f3304f01b4b 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1562,6 +1562,23 @@ class _BasePathTest(object): } self.assertEqual(given, {p / x for x in expect}) + def test_glob_many_open_files(self): + depth = 30 + P = self.cls + base = P(BASE) / 'deep' + p = P(base, *(['d']*depth)) + p.mkdir(parents=True) + 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_dotdot(self): # ".." is not special in globs. P = self.cls |