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

Method test_recursive_glob

Lib/test/test_glob.py:280–347  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

278 eq(self.hglob('**', 'G'), self.joins(*l2))
279
280 def test_recursive_glob(self):
281 eq = self.assertSequencesEqual_noorder
282 full = [('EF',), ('ZZZ',),
283 ('a',), ('a', 'D'),
284 ('a', 'bcd'),
285 ('a', 'bcd', 'EF'),
286 ('a', 'bcd', 'efg'),
287 ('a', 'bcd', 'efg', 'ha'),
288 ('aaa',), ('aaa', 'zzzF'),
289 ('aab',), ('aab', 'F'),
290 ]
291 if can_symlink():
292 full += [('sym1',), ('sym2',),
293 ('sym3',),
294 ('sym3', 'EF'),
295 ('sym3', 'efg'),
296 ('sym3', 'efg', 'ha'),
297 ]
298 eq(self.rglob('**'), self.joins(('',), *full))
299 eq(self.rglob(os.curdir, '**'),
300 self.joins((os.curdir, ''), *((os.curdir,) + i for i in full)))
301 dirs = [('a', ''), ('a', 'bcd', ''), ('a', 'bcd', 'efg', ''),
302 ('aaa', ''), ('aab', '')]
303 if can_symlink():
304 dirs += [('sym3', ''), ('sym3', 'efg', '')]
305 eq(self.rglob('**', ''), self.joins(('',), *dirs))
306
307 eq(self.rglob('a', '**'), self.joins(
308 ('a', ''), ('a', 'D'), ('a', 'bcd'), ('a', 'bcd', 'EF'),
309 ('a', 'bcd', 'efg'), ('a', 'bcd', 'efg', 'ha')))
310 eq(self.rglob('a**'), self.joins(('a',), ('aaa',), ('aab',)))
311 expect = [('a', 'bcd', 'EF'), ('EF',)]
312 if can_symlink():
313 expect += [('sym3', 'EF')]
314 eq(self.rglob('**', 'EF'), self.joins(*expect))
315 expect = [('a', 'bcd', 'EF'), ('aaa', 'zzzF'), ('aab', 'F'), ('EF',)]
316 if can_symlink():
317 expect += [('sym3', 'EF')]
318 eq(self.rglob('**', '*F'), self.joins(*expect))
319 eq(self.rglob('**', '*F', ''), [])
320 eq(self.rglob('**', 'bcd', '*'), self.joins(
321 ('a', 'bcd', 'EF'), ('a', 'bcd', 'efg')))
322 eq(self.rglob('a', '**', 'bcd'), self.joins(('a', 'bcd')))
323
324 with change_cwd(self.tempdir):
325 join = os.path.join
326 eq(glob.glob('**', recursive=True), [join(*i) for i in full])
327 eq(glob.glob(join('**', ''), recursive=True),
328 [join(*i) for i in dirs])
329 eq(glob.glob(join('**', '*'), recursive=True),
330 [join(*i) for i in full])
331 eq(glob.glob(join(os.curdir, '**'), recursive=True),
332 [join(os.curdir, '')] + [join(os.curdir, *i) for i in full])
333 eq(glob.glob(join(os.curdir, '**', ''), recursive=True),
334 [join(os.curdir, '')] + [join(os.curdir, *i) for i in dirs])
335 eq(glob.glob(join(os.curdir, '**', '*'), recursive=True),
336 [join(os.curdir, *i) for i in full])
337 eq(glob.glob(join('**','zz*F'), recursive=True),

Callers

nothing calls this directly

Calls 7

rglobMethod · 0.95
joinsMethod · 0.95
can_symlinkFunction · 0.90
change_cwdFunction · 0.90
eqFunction · 0.85
joinFunction · 0.50
globMethod · 0.45

Tested by

no test coverage detected