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

Method test_translate_matching

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

Source from the content-addressed store, hash-verified

424 eq(glob.glob1(self.tempdir, 'a*'), ['a', 'aaa', 'aab'])
425
426 def test_translate_matching(self):
427 match = re.compile(glob.translate('*')).match
428 self.assertIsNotNone(match('foo'))
429 self.assertIsNotNone(match('foo.bar'))
430 self.assertIsNone(match('.foo'))
431 match = re.compile(glob.translate('.*')).match
432 self.assertIsNotNone(match('.foo'))
433 match = re.compile(glob.translate('**', recursive=True)).match
434 self.assertIsNotNone(match('foo'))
435 self.assertIsNone(match('.foo'))
436 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
437 self.assertIsNone(match(os.path.join('foo', '.bar')))
438 self.assertIsNone(match(os.path.join('.foo', 'bar')))
439 self.assertIsNone(match(os.path.join('.foo', '.bar')))
440 match = re.compile(glob.translate('**/*', recursive=True)).match
441 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
442 self.assertIsNone(match(os.path.join('foo', '.bar')))
443 self.assertIsNone(match(os.path.join('.foo', 'bar')))
444 self.assertIsNone(match(os.path.join('.foo', '.bar')))
445 match = re.compile(glob.translate('*/**', recursive=True)).match
446 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
447 self.assertIsNone(match(os.path.join('foo', '.bar')))
448 self.assertIsNone(match(os.path.join('.foo', 'bar')))
449 self.assertIsNone(match(os.path.join('.foo', '.bar')))
450 match = re.compile(glob.translate('**/.bar', recursive=True)).match
451 self.assertIsNotNone(match(os.path.join('foo', '.bar')))
452 self.assertIsNone(match(os.path.join('.foo', '.bar')))
453 match = re.compile(glob.translate('**/*.*', recursive=True)).match
454 self.assertIsNone(match(os.path.join('foo', 'bar')))
455 self.assertIsNone(match(os.path.join('foo', '.bar')))
456 self.assertIsNotNone(match(os.path.join('foo', 'bar.txt')))
457 self.assertIsNone(match(os.path.join('foo', '.bar.txt')))
458
459 def test_translate(self):
460 def fn(pat):

Callers

nothing calls this directly

Calls 6

matchFunction · 0.85
assertIsNotNoneMethod · 0.80
assertIsNoneMethod · 0.80
compileMethod · 0.45
translateMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected