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

Method test_decode_warnings

Lib/test/test_codecs.py:2691–2722  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

coding_checkerFunction · 0.85
chrFunction · 0.85
assertWarnsRegexMethod · 0.80
assertWarnsMethod · 0.80
checkFunction · 0.70
decodeFunction · 0.50
upperMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected