MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_recursive_glob

Method test_recursive_glob

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected