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