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

Method test_streamwriter

Lib/test/multibytecodec_support.py:249–271  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

247 self.assertEqual(ostream.getvalue(), self.tstring[1])
248
249 def test_streamwriter(self):
250 readfuncs = ('read', 'readline', 'readlines')
251 UTF8Reader = codecs.getreader('utf-8')
252 for name in readfuncs:
253 for sizehint in [None] + list(range(1, 33)) + \
254 [64, 128, 256, 512, 1024]:
255 istream = UTF8Reader(BytesIO(self.tstring[1]))
256 ostream = self.writer(BytesIO())
257 func = getattr(istream, name)
258 while 1:
259 if sizehint is not None:
260 data = func(sizehint)
261 else:
262 data = func()
263
264 if not data:
265 break
266 if name == "readlines":
267 ostream.writelines(data)
268 else:
269 ostream.write(data)
270
271 self.assertEqual(ostream.getvalue(), self.tstring[0])
272
273 def test_streamwriter_reset_no_pending(self):
274 # Issue #23247: Calling reset() on a fresh StreamWriter instance

Callers

nothing calls this directly

Calls 9

BytesIOClass · 0.90
listClass · 0.85
getreaderMethod · 0.80
funcFunction · 0.70
writerMethod · 0.45
writelinesMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected