FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-116380: Revert addition of `test_iglob_iter_close` test by barneygale · Pull Request #130710 · python/cpython · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 1 addition & 23 deletions Lib/test/test_glob.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL