(self)
| 2689 | |
| 2690 | @unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered |
| 2691 | def test_decode_warnings(self): |
| 2692 | decode = codecs.unicode_escape_decode |
| 2693 | check = coding_checker(self, decode) |
| 2694 | for i in range(97, 123): |
| 2695 | b = bytes([i]) |
| 2696 | if b not in b'abfnrtuvx': |
| 2697 | with self.assertWarnsRegex(DeprecationWarning, |
| 2698 | r'"\\%c" is an invalid escape sequence' % i): |
| 2699 | check(b"\\" + b, "\\" + chr(i)) |
| 2700 | if b.upper() not in b'UN': |
| 2701 | with self.assertWarnsRegex(DeprecationWarning, |
| 2702 | r'"\\%c" is an invalid escape sequence' % (i-32)): |
| 2703 | check(b"\\" + b.upper(), "\\" + chr(i-32)) |
| 2704 | with self.assertWarnsRegex(DeprecationWarning, |
| 2705 | r'"\\8" is an invalid escape sequence'): |
| 2706 | check(br"\8", "\\8") |
| 2707 | with self.assertWarns(DeprecationWarning): |
| 2708 | check(br"\9", "\\9") |
| 2709 | with self.assertWarnsRegex(DeprecationWarning, |
| 2710 | r'"\\\xfa" is an invalid escape sequence') as cm: |
| 2711 | check(b"\\\xfa", "\\\xfa") |
| 2712 | for i in range(0o400, 0o1000): |
| 2713 | with self.assertWarnsRegex(DeprecationWarning, |
| 2714 | r'"\\%o" is an invalid octal escape sequence' % i): |
| 2715 | check(rb'\%o' % i, chr(i)) |
| 2716 | |
| 2717 | with self.assertWarnsRegex(DeprecationWarning, |
| 2718 | r'"\\z" is an invalid escape sequence'): |
| 2719 | self.assertEqual(decode(br'\x\z', 'ignore'), ('\\z', 4)) |
| 2720 | with self.assertWarnsRegex(DeprecationWarning, |
| 2721 | r'"\\501" is an invalid octal escape sequence'): |
| 2722 | self.assertEqual(decode(br'\x\501', 'ignore'), ('\u0141', 6)) |
| 2723 | |
| 2724 | def test_decode_errors(self): |
| 2725 | decode = codecs.unicode_escape_decode |
nothing calls this directly
no test coverage detected