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

Method test_other_escapes

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

Source from the content-addressed store, hash-verified

833 b"1aa! a", re.LOCALE).group(0), b"1aa! a")
834
835 def test_other_escapes(self):
836 self.checkPatternError("\\", 'bad escape (end of pattern)', 0)
837 self.assertEqual(re.match(r"\(", '(').group(), '(')
838 self.assertIsNone(re.match(r"\(", ')'))
839 self.assertEqual(re.match(r"\\", '\\').group(), '\\')
840 self.assertEqual(re.match(r"[\]]", ']').group(), ']')
841 self.assertIsNone(re.match(r"[\]]", '['))
842 self.assertEqual(re.match(r"[a\-c]", '-').group(), '-')
843 self.assertIsNone(re.match(r"[a\-c]", 'b'))
844 self.assertEqual(re.match(r"[\^a]+", 'a^').group(), 'a^')
845 self.assertIsNone(re.match(r"[\^a]+", 'b'))
846 re.purge() # for warnings
847 for c in 'ceghijklmopqyCEFGHIJKLMNOPQRTVXY':
848 with self.subTest(c):
849 self.assertRaises(re.PatternError, re.compile, '\\%c' % c)
850 for c in 'ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZ':
851 with self.subTest(c):
852 self.assertRaises(re.PatternError, re.compile, '[\\%c]' % c)
853
854 def test_named_unicode_escapes(self):
855 # test individual Unicode named escapes

Callers

nothing calls this directly

Calls 7

checkPatternErrorMethod · 0.95
assertIsNoneMethod · 0.80
subTestMethod · 0.80
assertEqualMethod · 0.45
groupMethod · 0.45
matchMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected