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.
gc_dump_improvements
Paul Sokolovsky 2016-05-02 14:35:45 +03:00
parent c816b89353
commit 566d8f1d7e
3 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,7 @@
import uio as io
try:
import uio as io
except ImportError:
import io
a = io.StringIO()
print('io.StringIO' in repr(a))

View File

@ -1,4 +1,7 @@
import uio as io
try:
import uio as io
except ImportError:
import io
# test __enter__/__exit__
with io.StringIO() as b:

View File

@ -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
if hasattr(sys, 'print_exception'):
print_exception = sys.print_exception