diff options
Diffstat (limited to 'tests/basics/io_bytesio_ext.py')
-rw-r--r-- | tests/basics/io_bytesio_ext.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/basics/io_bytesio_ext.py b/tests/basics/io_bytesio_ext.py new file mode 100644 index 000000000..e454b2fd9 --- /dev/null +++ b/tests/basics/io_bytesio_ext.py @@ -0,0 +1,28 @@ +# Extended stream operations on io.BytesIO +try: + import uio as io +except ImportError: + import io + +a = io.BytesIO(b"foobar") +a.seek(10) +print(a.read(10)) + +a = io.BytesIO() +print(a.seek(8)) +a.write(b"123") +print(a.getvalue()) + +print(a.seek(0, 1)) + +print(a.seek(-1, 2)) +a.write(b"0") +print(a.getvalue()) + +a.flush() +print(a.getvalue()) + +a.seek(0) +arr = bytearray(10) +print(a.readinto(arr)) +print(arr) |