Skip to content

Commit 566d8f1

Browse files
committed
tests: Make "io" modules fixes for CPython compatibility.
Previously, "import _io" worked on both CPython and MicroPython (essentially by a chance on CPython, as there's not guarantee that its contents will stay the same across versions), but as the module was renamed to uio, need to use more robust import sequence for compatibility.
1 parent c816b89 commit 566d8f1

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

tests/io/stringio1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import uio as io
1+
try:
2+
import uio as io
3+
except ImportError:
4+
import io
25

36
a = io.StringIO()
47
print('io.StringIO' in repr(a))

tests/io/stringio_with.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import uio as io
1+
try:
2+
import uio as io
3+
except ImportError:
4+
import io
25

36
# test __enter__/__exit__
47
with io.StringIO() as b:

tests/misc/print_exception.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import uio as io # uPy does not have io module builtin
1+
try:
2+
import uio as io
3+
except ImportError:
4+
import io
25
import sys
36
if hasattr(sys, 'print_exception'):
47
print_exception = sys.print_exception

0 commit comments

Comments
 (0)