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

Method test_other_escapes

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

Source from the content-addressed store, hash-verified

842 b"1aa! a", re.LOCALE).group(0), b"1aa! a")
843
844 def test_other_escapes(self):
845 self.checkPatternError("\\", 'bad escape (end of pattern)', 0)
846 self.assertEqual(re.match(r"\(", '(').group(), '(')
847 self.assertIsNone(re.match(r"\(", ')'))
848 self.assertEqual(re.match(r"\\", '\\').group(), '\\')
849 self.assertEqual(re.match(r"[\]]", ']').group(), ']')
850 self.assertIsNone(re.match(r"[\]]", '['))
851 self.assertEqual(re.match(r"[a\-c]", '-').group(), '-')
852 self.assertIsNone(re.match(r"[a\-c]", 'b'))
853 self.assertEqual(re.match(r"[\^a]+", 'a^').group(), 'a^')
854 self.assertIsNone(re.match(r"[\^a]+", 'b'))
855 re.purge() # for warnings
856 for c in 'ceghijklmopqyCEFGHIJKLMNOPQRTVXY':
857 with self.subTest(c):
858 self.assertRaises(re.PatternError, re.compile, '\\%c' % c)
859 for c in 'ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZ':
860 with self.subTest(c):
861 self.assertRaises(re.PatternError, re.compile, '[\\%c]' % c)
862
863 def test_named_unicode_escapes(self):
864 # test individual Unicode named escapes

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected