tests/basics: Skip tests of io module individually using SKIP.

Instead of using a feature check.  This is more consistent with how other
optional modules are skipped.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-08-11 11:45:55 +10:00
parent e2744ce679
commit 54e6cfc6e3
12 changed files with 47 additions and 28 deletions

View File

@@ -1,9 +1,9 @@
import io
try:
import io
io.BytesIO
io.BufferedWriter
except AttributeError:
except (AttributeError, ImportError):
print('SKIP')
raise SystemExit

View File

@@ -1,6 +1,12 @@
# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
b = b"foobar"
a = io.BytesIO(b)

View File

@@ -1,5 +1,11 @@
# Extended stream operations on io.BytesIO
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
a = io.BytesIO(b"foobar")
a.seek(10)
print(a.read(10))

View File

@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
a = io.BytesIO(b"foobar")
try:
a.seek(-10)

View File

@@ -1,8 +1,9 @@
import io
try:
import io
io.IOBase
except AttributeError:
print('SKIP')
except (AttributeError, ImportError):
print("SKIP")
raise SystemExit

View File

@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
a = io.StringIO()
print('io.StringIO' in repr(a))
print(a.getvalue())

View File

@@ -1,7 +1,11 @@
# Checks that an instance type inheriting from a native base that uses
# MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter.
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
a = io.StringIO()
a.write("hello\nworld\nmicro\npython\n")

View File

@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit
# test __enter__/__exit__
with io.StringIO() as b:
b.write("foo")

View File

@@ -1,10 +1,11 @@
# This tests extended (MicroPython-specific) form of write:
# write(buf, len) and write(buf, offset, len)
import io
try:
import io
io.BytesIO
except AttributeError:
except (AttributeError, ImportError):
print('SKIP')
raise SystemExit