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

Method test_incremental_errors

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

Source from the content-addressed store, hash-verified

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.
907 # See issue #24214
908 cases = [b'\x80', b'\xBF', b'\xC0', b'\xC1', b'\xF5', b'\xF6', b'\xFF']
909 for prefix in (b'\xC2', b'\xDF', b'\xE0', b'\xE0\xA0', b'\xEF',
910 b'\xEF\xBF', b'\xF0', b'\xF0\x90', b'\xF0\x90\x80',
911 b'\xF4', b'\xF4\x8F', b'\xF4\x8F\xBF'):
912 for suffix in b'\x7F', b'\xC0':
913 cases.append(prefix + suffix)
914 cases.extend((b'\xE0\x80', b'\xE0\x9F', b'\xED\xA0\x80',
915 b'\xED\xBF\xBF', b'\xF0\x80', b'\xF0\x8F', b'\xF4\x90'))
916
917 for data in cases:
918 with self.subTest(data=data):
919 dec = codecs.getincrementaldecoder(self.encoding)()
920 self.assertRaises(UnicodeDecodeError, dec.decode, data)
921
922
923class UTF7Test(ReadTest, unittest.TestCase):

Callers

nothing calls this directly

Calls 4

subTestMethod · 0.80
appendMethod · 0.45
extendMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected