mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
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).
This commit is contained in:
parent
5a4f82f457
commit
f9dc2ad890
3 changed files with 59 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue