MCPcopy Index your code
hub / github.com/python/cpython / test_stream_bom

Method test_stream_bom

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

Source from the content-addressed store, hash-verified

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