circuitpython/tests/basics/io_buffered_writer.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
602 B
Python
Raw Normal View History

import uio as io
2016-03-25 09:01:19 -04:00
try:
io.BytesIO
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
2016-03-25 09:01:19 -04:00
bts = io.BytesIO()
buf = io.BufferedWriter(bts, 8)
buf.write(b"foobar")
print(bts.getvalue())
buf.write(b"foobar")
# CPython has different flushing policy, so value below is different
print(bts.getvalue())
buf.flush()
print(bts.getvalue())
buf.flush()
print(bts.getvalue())
# special case when alloc is a factor of total buffer length
bts = io.BytesIO()
buf = io.BufferedWriter(bts, 1)
buf.write(b"foo")
print(bts.getvalue())
# hashing a BufferedWriter
print(type(hash(buf)))