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

Method test_re_groupref

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

Source from the content-addressed store, hash-verified

719 'invalid group reference %d' % MAXGROUPS, 10)
720
721 def test_re_groupref(self):
722 self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', '|a|').groups(),
723 ('|', 'a'))
724 self.assertEqual(re.match(r'^(\|)?([^()]+)\1?$', 'a').groups(),
725 (None, 'a'))
726 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', 'a|'))
727 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', '|a'))
728 self.assertEqual(re.match(r'^(?:(a)|c)(\1)$', 'aa').groups(),
729 ('a', 'a'))
730 self.assertEqual(re.match(r'^(?:(a)|c)(\1)?$', 'c').groups(),
731 (None, None))
732
733 self.checkPatternError(r'(abc\1)', 'cannot refer to an open group', 4)
734
735 def test_groupdict(self):
736 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