summaryrefslogtreecommitdiffstatshomepage
path: root/tests/io/buffered_writer.py
blob: 0fe8a7730912bd9691694bc08e4bed8594e1b630 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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())