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

Method test_stream_bom

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

Source from the content-addressed store, hash-verified

1120 self.assertEqual(d.decode(s.encode("utf-8-sig")), s)
1121
1122 def test_stream_bom(self):
1123 unistring = "ABC\u00A1\u2200XYZ"
1124 bytestring = codecs.BOM_UTF8 + b"ABC\xC2\xA1\xE2\x88\x80XYZ"
1125
1126 reader = codecs.getreader("utf-8-sig")
1127 for sizehint in [None] + list(range(1, 11)) + \
1128 [64, 128, 256, 512, 1024]:
1129 istream = reader(io.BytesIO(bytestring))
1130 ostream = io.StringIO()
1131 while 1:
1132 if sizehint is not None:
1133 data = istream.read(sizehint)
1134 else:
1135 data = istream.read()
1136
1137 if not data:
1138 break
1139 ostream.write(data)
1140
1141 got = ostream.getvalue()
1142 self.assertEqual(got, unistring)
1143
1144 def test_stream_bare(self):
1145 unistring = "ABC\u00A1\u2200XYZ"

Callers

nothing calls this directly

Calls 7

getvalueMethod · 0.95
listClass · 0.85
readerFunction · 0.85
getreaderMethod · 0.80
readMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected