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

Method test_translate_matching

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

Source from the content-addressed store, hash-verified

393 self.assertEqual(next(it), p)
394
395 def test_translate_matching(self):
396 match = re.compile(glob.translate('*')).match
397 self.assertIsNotNone(match('foo'))
398 self.assertIsNotNone(match('foo.bar'))
399 self.assertIsNone(match('.foo'))
400 match = re.compile(glob.translate('.*')).match
401 self.assertIsNotNone(match('.foo'))
402 match = re.compile(glob.translate('**', recursive=True)).match
403 self.assertIsNotNone(match('foo'))
404 self.assertIsNone(match('.foo'))
405 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
406 self.assertIsNone(match(os.path.join('foo', '.bar')))
407 self.assertIsNone(match(os.path.join('.foo', 'bar')))
408 self.assertIsNone(match(os.path.join('.foo', '.bar')))
409 match = re.compile(glob.translate('**/*', recursive=True)).match
410 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
411 self.assertIsNone(match(os.path.join('foo', '.bar')))
412 self.assertIsNone(match(os.path.join('.foo', 'bar')))
413 self.assertIsNone(match(os.path.join('.foo', '.bar')))
414 match = re.compile(glob.translate('*/**', recursive=True)).match
415 self.assertIsNotNone(match(os.path.join('foo', 'bar')))
416 self.assertIsNone(match(os.path.join('foo', '.bar')))
417 self.assertIsNone(match(os.path.join('.foo', 'bar')))
418 self.assertIsNone(match(os.path.join('.foo', '.bar')))
419 match = re.compile(glob.translate('**/.bar', recursive=True)).match
420 self.assertIsNotNone(match(os.path.join('foo', '.bar')))
421 self.assertIsNone(match(os.path.join('.foo', '.bar')))
422 match = re.compile(glob.translate('**/*.*', recursive=True)).match
423 self.assertIsNone(match(os.path.join('foo', 'bar')))
424 self.assertIsNone(match(os.path.join('foo', '.bar')))
425 self.assertIsNotNone(match(os.path.join('foo', 'bar.txt')))
426 self.assertIsNone(match(os.path.join('foo', '.bar.txt')))
427
428 def test_translate(self):
429 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