Skip to content

Commit 88f60de

Browse files
committed
tests: Add test for io.BufferedWriter.
1 parent 2c81b9b commit 88f60de

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/io/buffered_writer.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import _io as io
2+
3+
try:
4+
io.BytesIO
5+
io.BufferedWriter
6+
except AttributeError:
7+
import sys
8+
print('SKIP')
9+
sys.exit()
10+
11+
bts = io.BytesIO()
12+
buf = io.BufferedWriter(bts, 8)
13+
14+
buf.write(b"foobar")
15+
print(bts.getvalue())
16+
buf.write(b"foobar")
17+
# CPython has different flushing policy, so value below is different
18+
print(bts.getvalue())
19+
buf.flush()
20+
print(bts.getvalue())
21+
buf.flush()
22+
print(bts.getvalue())

tests/io/buffered_writer.py.exp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
b''
2+
b'foobarfo'
3+
b'foobarfoobar'
4+
b'foobarfoobar'

0 commit comments

Comments
 (0)