diff options
author | andrei kulakov <andrei.avk@gmail.com> | 2021-12-18 14:23:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 14:23:34 (GMT) |
commit | ae36cd1e792db9d6db4c6847ec2a7d50a71f2b68 (patch) | |
tree | 3e223cb1c046e119dbce83550d7bf5a6ed213a76 /Lib/test | |
parent | 6f2df4295123f8b961d49474b7668f7564a534a4 (diff) | |
download | cpython-ae36cd1e792db9d6db4c6847ec2a7d50a71f2b68.zip cpython-ae36cd1e792db9d6db4c6847ec2a7d50a71f2b68.tar.gz cpython-ae36cd1e792db9d6db4c6847ec2a7d50a71f2b68.tar.bz2 |
bpo-37578: glob.glob -- added include_hidden parameter (GH-30153)
Automerge-Triggered-By: GH:asvetlov
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_glob.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index 96db31b..f4b5821 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -30,6 +30,7 @@ class GlobTests(unittest.TestCase): self.mktemp('aab', 'F') self.mktemp('.aa', 'G') self.mktemp('.bb', 'H') + self.mktemp('.bb', '.J') self.mktemp('aaa', 'zzzF') self.mktemp('ZZZ') self.mktemp('EF') @@ -56,7 +57,9 @@ class GlobTests(unittest.TestCase): pattern = os.path.join(*parts) p = os.path.join(self.tempdir, pattern) res = glob.glob(p, **kwargs) + res2 = glob.iglob(p, **kwargs) self.assertCountEqual(glob.iglob(p, **kwargs), res) + bres = [os.fsencode(x) for x in res] self.assertCountEqual(glob.glob(os.fsencode(p), **kwargs), bres) self.assertCountEqual(glob.iglob(os.fsencode(p), **kwargs), bres) @@ -249,6 +252,17 @@ class GlobTests(unittest.TestCase): def rglob(self, *parts, **kwargs): return self.glob(*parts, recursive=True, **kwargs) + def hglob(self, *parts, **kwargs): + return self.glob(*parts, include_hidden=True, **kwargs) + + def test_hidden_glob(self): + eq = self.assertSequencesEqual_noorder + l = [('aaa',), ('.aa',)] + eq(self.hglob('?aa'), self.joins(*l)) + eq(self.hglob('*aa'), self.joins(*l)) + l2 = [('.aa','G',)] + eq(self.hglob('**', 'G'), self.joins(*l2)) + def test_recursive_glob(self): eq = self.assertSequencesEqual_noorder full = [('EF',), ('ZZZ',), @@ -314,6 +328,10 @@ class GlobTests(unittest.TestCase): expect += [join('sym3', 'EF')] eq(glob.glob(join('**', 'EF'), recursive=True), expect) + rec = [('.bb','H'), ('.bb','.J'), ('.aa','G'), ('.aa',), ('.bb',)] + eq(glob.glob('**', recursive=True, include_hidden=True), + [join(*i) for i in full+rec]) + def test_glob_many_open_files(self): depth = 30 base = os.path.join(self.tempdir, 'deep') |