tests: Add test for io.BufferedWriter.
This commit is contained in:
parent
2c81b9be28
commit
88f60de914
22
tests/io/buffered_writer.py
Normal file
22
tests/io/buffered_writer.py
Normal file
@ -0,0 +1,22 @@
|
||||
import _io as io
|
||||
|
||||
try:
|
||||
io.BytesIO
|
||||
io.BufferedWriter
|
||||
except AttributeError:
|
||||
import sys
|
||||
print('SKIP')
|
||||
sys.exit()
|
||||
|
||||
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())
|
4
tests/io/buffered_writer.py.exp
Normal file
4
tests/io/buffered_writer.py.exp
Normal file
@ -0,0 +1,4 @@
|
||||
b''
|
||||
b'foobarfo'
|
||||
b'foobarfoobar'
|
||||
b'foobarfoobar'
|
Loading…
x
Reference in New Issue
Block a user