(self)
| 1201 | check(br"[\x410]", b"[A0]") |
| 1202 | |
| 1203 | def test_warnings(self): |
| 1204 | decode = codecs.escape_decode |
| 1205 | check = coding_checker(self, decode) |
| 1206 | for i in range(97, 123): |
| 1207 | b = bytes([i]) |
| 1208 | if b not in b'abfnrtvx': |
| 1209 | with self.assertWarnsRegex(DeprecationWarning, |
| 1210 | r'"\\%c" is an invalid escape sequence' % i): |
| 1211 | check(b"\\" + b, b"\\" + b) |
| 1212 | with self.assertWarnsRegex(DeprecationWarning, |
| 1213 | r'"\\%c" is an invalid escape sequence' % (i-32)): |
| 1214 | check(b"\\" + b.upper(), b"\\" + b.upper()) |
| 1215 | with self.assertWarnsRegex(DeprecationWarning, |
| 1216 | r'"\\8" is an invalid escape sequence'): |
| 1217 | check(br"\8", b"\\8") |
| 1218 | with self.assertWarns(DeprecationWarning): |
| 1219 | check(br"\9", b"\\9") |
| 1220 | with self.assertWarnsRegex(DeprecationWarning, |
| 1221 | r'"\\\xfa" is an invalid escape sequence') as cm: |
| 1222 | check(b"\\\xfa", b"\\\xfa") |
| 1223 | for i in range(0o400, 0o1000): |
| 1224 | with self.assertWarnsRegex(DeprecationWarning, |
| 1225 | r'"\\%o" is an invalid octal escape sequence' % i): |
| 1226 | check(rb'\%o' % i, bytes([i & 0o377])) |
| 1227 | |
| 1228 | with self.assertWarnsRegex(DeprecationWarning, |
| 1229 | r'"\\z" is an invalid escape sequence'): |
| 1230 | self.assertEqual(decode(br'\x\z', 'ignore'), (b'\\z', 4)) |
| 1231 | with self.assertWarnsRegex(DeprecationWarning, |
| 1232 | r'"\\501" is an invalid octal escape sequence'): |
| 1233 | self.assertEqual(decode(br'\x\501', 'ignore'), (b'A', 6)) |
| 1234 | |
| 1235 | def test_errors(self): |
| 1236 | decode = codecs.escape_decode |
nothing calls this directly
no test coverage detected