MCPcopy Index your code
hub / github.com/python/cpython / glob

Method glob

Lib/test/test_glob.py:60–108  ·  view source on GitHub ↗
(self, *parts, **kwargs)

Source from the content-addressed store, hash-verified

58 shutil.rmtree(self.tempdir)
59
60 def glob(self, *parts, **kwargs):
61 if len(parts) == 1:
62 pattern = parts[0]
63 else:
64 pattern = os.path.join(*parts)
65 p = os.path.join(self.tempdir, pattern)
66 res = glob.glob(p, **kwargs)
67 res2 = glob.iglob(p, **kwargs)
68 self.assertCountEqual(glob.iglob(p, **kwargs), res)
69
70 bres = [os.fsencode(x) for x in res]
71 self.assertCountEqual(glob.glob(os.fsencode(p), **kwargs), bres)
72 self.assertCountEqual(glob.iglob(os.fsencode(p), **kwargs), bres)
73
74 with change_cwd(self.tempdir):
75 res2 = glob.glob(pattern, **kwargs)
76 for x in res2:
77 self.assertFalse(os.path.isabs(x), x)
78 if pattern == '**' or pattern == '**' + os.sep:
79 expected = res[1:]
80 else:
81 expected = res
82 self.assertCountEqual([os.path.join(self.tempdir, x) for x in res2],
83 expected)
84 self.assertCountEqual(glob.iglob(pattern, **kwargs), res2)
85 bpattern = os.fsencode(pattern)
86 bres2 = [os.fsencode(x) for x in res2]
87 self.assertCountEqual(glob.glob(bpattern, **kwargs), bres2)
88 self.assertCountEqual(glob.iglob(bpattern, **kwargs), bres2)
89
90 self.assertCountEqual(glob.glob(pattern, root_dir=self.tempdir, **kwargs), res2)
91 self.assertCountEqual(glob.iglob(pattern, root_dir=self.tempdir, **kwargs), res2)
92 btempdir = os.fsencode(self.tempdir)
93 self.assertCountEqual(
94 glob.glob(bpattern, root_dir=btempdir, **kwargs), bres2)
95 self.assertCountEqual(
96 glob.iglob(bpattern, root_dir=btempdir, **kwargs), bres2)
97
98 if self.dir_fd is not None:
99 self.assertCountEqual(
100 glob.glob(pattern, dir_fd=self.dir_fd, **kwargs), res2)
101 self.assertCountEqual(
102 glob.iglob(pattern, dir_fd=self.dir_fd, **kwargs), res2)
103 self.assertCountEqual(
104 glob.glob(bpattern, dir_fd=self.dir_fd, **kwargs), bres2)
105 self.assertCountEqual(
106 glob.iglob(bpattern, dir_fd=self.dir_fd, **kwargs), bres2)
107
108 return res
109
110 def assertSequencesEqual_noorder(self, l1, l2):
111 l1 = list(l1)

Callers 15

test_glob_literalMethod · 0.95
test_glob_symlinksMethod · 0.95
rglobMethod · 0.95
hglobMethod · 0.95
test_random_filesMethod · 0.45
BaseTestClass · 0.45
files_to_testMethod · 0.45
test_getlongpathnameMethod · 0.45

Calls 5

change_cwdFunction · 0.90
assertCountEqualMethod · 0.80
assertFalseMethod · 0.80
joinMethod · 0.45
isabsMethod · 0.45

Tested by

no test coverage detected