diff options
| author | Damien George | 2018-06-20 17:11:58 +1000 |
|---|---|---|
| committer | Damien George | 2018-06-27 16:55:05 +1000 |
| commit | 726804ea405483872ebc93772aea0ab0bfce0bcf (patch) | |
| tree | f3ee9544b5ea83dfa671e40a4341bf91524e785c /tests/io | |
| parent | bc6c56d75d1b954b42b01dc8e10e283523b2e902 (diff) | |
tests: Move non-filesystem io tests to basics dir with io_ prefix.
Diffstat (limited to 'tests/io')
| -rw-r--r-- | tests/io/buffered_writer.py | 27 | ||||
| -rw-r--r-- | tests/io/buffered_writer.py.exp | 5 | ||||
| -rw-r--r-- | tests/io/bytesio_cow.py | 20 | ||||
| -rw-r--r-- | tests/io/bytesio_ext.py | 28 | ||||
| -rw-r--r-- | tests/io/bytesio_ext2.py | 13 | ||||
| -rw-r--r-- | tests/io/bytesio_ext2.py.exp | 1 | ||||
| -rw-r--r-- | tests/io/iobase.py | 19 | ||||
| -rw-r--r-- | tests/io/stringio1.py | 45 | ||||
| -rw-r--r-- | tests/io/stringio_with.py | 9 | ||||
| -rw-r--r-- | tests/io/write_ext.py | 26 | ||||
| -rw-r--r-- | tests/io/write_ext.py.exp | 5 |
11 files changed, 0 insertions, 198 deletions
diff --git a/tests/io/buffered_writer.py b/tests/io/buffered_writer.py deleted file mode 100644 index c2cedb991..000000000 --- a/tests/io/buffered_writer.py +++ /dev/null @@ -1,27 +0,0 @@ -import uio as io - -try: - io.BytesIO - io.BufferedWriter -except AttributeError: - print('SKIP') - raise SystemExit - -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()) - -# special case when alloc is a factor of total buffer length -bts = io.BytesIO() -buf = io.BufferedWriter(bts, 1) -buf.write(b"foo") -print(bts.getvalue()) diff --git a/tests/io/buffered_writer.py.exp b/tests/io/buffered_writer.py.exp deleted file mode 100644 index d086935a9..000000000 --- a/tests/io/buffered_writer.py.exp +++ /dev/null @@ -1,5 +0,0 @@ -b'' -b'foobarfo' -b'foobarfoobar' -b'foobarfoobar' -b'foo' diff --git a/tests/io/bytesio_cow.py b/tests/io/bytesio_cow.py deleted file mode 100644 index 92654a000..000000000 --- a/tests/io/bytesio_cow.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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()) diff --git a/tests/io/bytesio_ext.py b/tests/io/bytesio_ext.py deleted file mode 100644 index e454b2fd9..000000000 --- a/tests/io/bytesio_ext.py +++ /dev/null @@ -1,28 +0,0 @@ -# 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) diff --git a/tests/io/bytesio_ext2.py b/tests/io/bytesio_ext2.py deleted file mode 100644 index 8f624fd58..000000000 --- a/tests/io/bytesio_ext2.py +++ /dev/null @@ -1,13 +0,0 @@ -try: - import uio as io -except ImportError: - import io - -a = io.BytesIO(b"foobar") -try: - a.seek(-10) -except Exception as e: - # CPython throws ValueError, but MicroPython has consistent stream - # interface, so BytesIO raises the same error as a real file, which - # is OSError(EINVAL). - print(type(e), e.args[0] > 0) diff --git a/tests/io/bytesio_ext2.py.exp b/tests/io/bytesio_ext2.py.exp deleted file mode 100644 index 724aaf63a..000000000 --- a/tests/io/bytesio_ext2.py.exp +++ /dev/null @@ -1 +0,0 @@ -<class 'OSError'> True diff --git a/tests/io/iobase.py b/tests/io/iobase.py deleted file mode 100644 index 6f554b00f..000000000 --- a/tests/io/iobase.py +++ /dev/null @@ -1,19 +0,0 @@ -try: - import uio as io -except: - import io - -try: - io.IOBase -except AttributeError: - print('SKIP') - raise SystemExit - - -class MyIO(io.IOBase): - def write(self, buf): - # CPython and uPy pass in different types for buf (str vs bytearray) - print('write', len(buf)) - return len(buf) - -print('test', file=MyIO()) diff --git a/tests/io/stringio1.py b/tests/io/stringio1.py deleted file mode 100644 index 9f7c1e44e..000000000 --- a/tests/io/stringio1.py +++ /dev/null @@ -1,45 +0,0 @@ -try: - import uio as io -except ImportError: - import io - -a = io.StringIO() -print('io.StringIO' in repr(a)) -print(a.getvalue()) -print(a.read()) - -a = io.StringIO("foobar") -print(a.getvalue()) -print(a.read()) -print(a.read()) - -a = io.StringIO() -a.write("foo") -print(a.getvalue()) - -a = io.StringIO("foo") -a.write("12") -print(a.getvalue()) - -a = io.StringIO("foo") -a.write("123") -print(a.getvalue()) - -a = io.StringIO("foo") -a.write("1234") -print(a.getvalue()) - -a = io.StringIO() -a.write("foo") -print(a.read()) - -a = io.StringIO() -a.close() -for f in [a.read, a.getvalue, lambda:a.write("")]: - # CPython throws for operations on closed I/O, MicroPython makes - # the underlying string empty unless MICROPY_CPYTHON_COMPAT defined - try: - f() - print("ValueError") - except ValueError: - print("ValueError") diff --git a/tests/io/stringio_with.py b/tests/io/stringio_with.py deleted file mode 100644 index c35975445..000000000 --- a/tests/io/stringio_with.py +++ /dev/null @@ -1,9 +0,0 @@ -try: - import uio as io -except ImportError: - import io - -# test __enter__/__exit__ -with io.StringIO() as b: - b.write("foo") - print(b.getvalue()) diff --git a/tests/io/write_ext.py b/tests/io/write_ext.py deleted file mode 100644 index 5a6eaa35c..000000000 --- a/tests/io/write_ext.py +++ /dev/null @@ -1,26 +0,0 @@ -# This tests extended (MicroPython-specific) form of write: -# write(buf, len) and write(buf, offset, len) -import uio - -try: - uio.BytesIO -except AttributeError: - print('SKIP') - raise SystemExit - -buf = uio.BytesIO() - -buf.write(b"foo", 2) -print(buf.getvalue()) - -buf.write(b"foo", 100) -print(buf.getvalue()) - -buf.write(b"foobar", 1, 3) -print(buf.getvalue()) - -buf.write(b"foobar", 1, 100) -print(buf.getvalue()) - -buf.write(b"foobar", 100, 100) -print(buf.getvalue()) diff --git a/tests/io/write_ext.py.exp b/tests/io/write_ext.py.exp deleted file mode 100644 index 0f9c6bfbc..000000000 --- a/tests/io/write_ext.py.exp +++ /dev/null @@ -1,5 +0,0 @@ -b'fo' -b'fofoo' -b'fofoooob' -b'fofooooboobar' -b'fofooooboobar' |
