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

Method test_re_groupref

Lib/test/test_re.py:710–722  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

708 'invalid group reference %d' % MAXGROUPS, 10)
709
710 def test_re_groupref(self):
711 self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', '|a|').groups(),
712 ('|', 'a'))
713 self.assertEqual(re.match(r'^(\|)?([^()]+)\1?$', 'a').groups(),
714 (None, 'a'))
715 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', 'a|'))
716 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', '|a'))
717 self.assertEqual(re.match(r'^(?:(a)|c)(\1)$', 'aa').groups(),
718 ('a', 'a'))
719 self.assertEqual(re.match(r'^(?:(a)|c)(\1)?$', 'c').groups(),
720 (None, None))
721
722 self.checkPatternError(r'(abc\1)', 'cannot refer to an open group', 4)
723
724 def test_groupdict(self):
725 self.assertEqual(re.match('(?P<first>first) (?P<second>second)',

Callers

nothing calls this directly

Calls 5

checkPatternErrorMethod · 0.95
assertIsNoneMethod · 0.80
assertEqualMethod · 0.45
groupsMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected