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

Method test_surrogatepass_handler

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

Source from the content-addressed store, hash-verified

884 self.assertEqual(exc.object[exc.start:exc.end], '\uD800\uDFFF')
885
886 def test_surrogatepass_handler(self):
887 self.assertEqual("abc\ud800def".encode(self.encoding, "surrogatepass"),
888 self.BOM + b"abc\xed\xa0\x80def")
889 self.assertEqual("\U00010fff\uD800".encode(self.encoding, "surrogatepass"),
890 self.BOM + b"\xf0\x90\xbf\xbf\xed\xa0\x80")
891 self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "surrogatepass"),
892 self.BOM + b'[\xed\xa0\x80\xed\xb2\x80]')
893
894 self.assertEqual(b"abc\xed\xa0\x80def".decode(self.encoding, "surrogatepass"),
895 "abc\ud800def")
896 self.assertEqual(b"\xf0\x90\xbf\xbf\xed\xa0\x80".decode(self.encoding, "surrogatepass"),
897 "\U00010fff\uD800")
898
899 self.assertTrue(codecs.lookup_error("surrogatepass"))
900 with self.assertRaises(UnicodeDecodeError):
901 b"abc\xed\xa0".decode(self.encoding, "surrogatepass")
902 with self.assertRaises(UnicodeDecodeError):
903 b"abc\xed\xa0z".decode(self.encoding, "surrogatepass")
904
905 def test_incremental_errors(self):
906 # Test that the incremental decoder can fail with final=False.

Callers

nothing calls this directly

Calls 6

assertTrueMethod · 0.80
lookup_errorMethod · 0.80
assertEqualMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected