Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-116380: Revert addition of test_iglob_iter_close test #130710

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions Lib/test/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import shutil
import sys
import unittest
import unittest.mock
import warnings

from test import support
Expand All @@ -13,9 +12,6 @@
can_symlink, create_empty_file, change_cwd)


_supports_dir_fd = {os.open, os.stat} <= os.supports_dir_fd and os.scandir in os.supports_fd


class GlobTests(unittest.TestCase):
dir_fd = None

Expand Down Expand Up @@ -53,7 +49,7 @@ def setUp(self):
def open_dirfd(self):
if self.dir_fd is not None:
os.close(self.dir_fd)
if _supports_dir_fd:
if {os.open, os.stat} <= os.supports_dir_fd and os.scandir in os.supports_fd:
self.dir_fd = os.open(self.tempdir, os.O_RDONLY | os.O_DIRECTORY)
else:
self.dir_fd = None
Expand Down Expand Up @@ -409,24 +405,6 @@ def test_glob_above_recursion_limit(self):
with infinite_recursion(depth - 5):
glob.glob(pattern, recursive=True)

@unittest.skipUnless(_supports_dir_fd, "Needs support for iglob(dir_fd=...)")
def test_iglob_iter_close(self):
base = os.path.join(self.tempdir, 'deep')
p = os.path.join(base, *(['d'] * 10))
os.makedirs(p)
with (
unittest.mock.patch("glob._StringGlobber.open", wraps=os.open) as os_open,
unittest.mock.patch("glob._StringGlobber.close", wraps=os.close) as os_close
):
self.assertEqual(os_open.call_count, os_close.call_count)
iter = glob.iglob('**/*/d', dir_fd=self.dir_fd, recursive=True)
self.assertEqual(os_open.call_count, os_close.call_count)
self.assertEqual(next(iter), 'deep/d')
self.assertEqual(next(iter), 'deep/d/d')
self.assertGreater(os_open.call_count, os_close.call_count)
iter.close()
self.assertEqual(os_open.call_count, os_close.call_count)

def test_glob0(self):
with self.assertWarns(DeprecationWarning):
glob.glob0(self.tempdir, 'a')
Expand Down
Loading