(self)
| 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. |
nothing calls this directly
no test coverage detected