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.
This commit is contained in:
parent
c816b89353
commit
566d8f1d7e
|
@ -1,4 +1,7 @@
|
||||||
import uio as io
|
try:
|
||||||
|
import uio as io
|
||||||
|
except ImportError:
|
||||||
|
import io
|
||||||
|
|
||||||
a = io.StringIO()
|
a = io.StringIO()
|
||||||
print('io.StringIO' in repr(a))
|
print('io.StringIO' in repr(a))
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import uio as io
|
try:
|
||||||
|
import uio as io
|
||||||
|
except ImportError:
|
||||||
|
import io
|
||||||
|
|
||||||
# test __enter__/__exit__
|
# test __enter__/__exit__
|
||||||
with io.StringIO() as b:
|
with io.StringIO() as b:
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import uio as io # uPy does not have io module builtin
|
try:
|
||||||
|
import uio as io
|
||||||
|
except ImportError:
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
if hasattr(sys, 'print_exception'):
|
if hasattr(sys, 'print_exception'):
|
||||||
print_exception = sys.print_exception
|
print_exception = sys.print_exception
|
||||||
|
|
Loading…
Reference in New Issue