diff options
Diffstat (limited to 'tests/io/bytesio_cow.py')
-rw-r--r-- | tests/io/bytesio_cow.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/io/bytesio_cow.py b/tests/io/bytesio_cow.py new file mode 100644 index 0000000000..92654a0003 --- /dev/null +++ b/tests/io/bytesio_cow.py @@ -0,0 +1,20 @@ +# Make sure that write operations on io.BytesIO don't +# change original object it was constructed from. +try: + import uio as io +except ImportError: + import io + +b = b"foobar" + +a = io.BytesIO(b) +a.write(b"1") +print(b) +print(a.getvalue()) + +b = bytearray(b"foobar") + +a = io.BytesIO(b) +a.write(b"1") +print(b) +print(a.getvalue()) |