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

Method test_re_groupref_exists_errors

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

Source from the content-addressed store, hash-verified

676 self.assertEqual(re.match(pat, 'xc8yz').span(), (0, 5))
677
678 def test_re_groupref_exists_errors(self):
679 self.checkPatternError(r'(?P<a>)(?(0)a|b)', 'bad group number', 10)
680 self.checkPatternError(r'()(?(-1)a|b)',
681 "bad character in group name '-1'", 5)
682 self.checkPatternError(r'()(?(+1)a|b)',
683 "bad character in group name '+1'", 5)
684 self.checkPatternError(r'()'*10 + r'(?(1_0)a|b)',
685 "bad character in group name '1_0'", 23)
686 self.checkPatternError(r'()(?( 1 )a|b)',
687 "bad character in group name ' 1 '", 5)
688 self.checkPatternError(r'()(?(㊀)a|b)',
689 "bad character in group name '㊀'", 5)
690 self.checkPatternError(r'()(?(¹)a|b)',
691 "bad character in group name '¹'", 5)
692 self.checkPatternError(r'()(?(१)a|b)',
693 "bad character in group name '१'", 5)
694 self.checkPatternError(r'()(?(1',
695 "missing ), unterminated name", 5)
696 self.checkPatternError(r'()(?(1)a',
697 "missing ), unterminated subpattern", 2)
698 self.checkPatternError(r'()(?(1)a|b',
699 'missing ), unterminated subpattern', 2)
700 self.checkPatternError(r'()(?(1)a|b|c',
701 'conditional backref with more than '
702 'two branches', 10)
703 self.checkPatternError(r'()(?(1)a|b|c)',
704 'conditional backref with more than '
705 'two branches', 10)
706 self.checkPatternError(r'()(?(2)a)',
707 "invalid group reference 2", 5)
708
709 def test_re_groupref_exists_validation_bug(self):
710 for i in range(256):

Callers

nothing calls this directly

Calls 1

checkPatternErrorMethod · 0.95

Tested by

no test coverage detected