From 566d8f1d7e1eb1a0cd595d4e76401ea5d54b0ef4 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Mon, 2 May 2016 14:35:45 +0300
Subject: [PATCH] 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.
---
 tests/io/stringio1.py         | 5 ++++-
 tests/io/stringio_with.py     | 5 ++++-
 tests/misc/print_exception.py | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/tests/io/stringio1.py b/tests/io/stringio1.py
index a224c5b0c..fa50f282e 100644
--- a/tests/io/stringio1.py
+++ b/tests/io/stringio1.py
@@ -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))
diff --git a/tests/io/stringio_with.py b/tests/io/stringio_with.py
index 6dc48c893..c35975445 100644
--- a/tests/io/stringio_with.py
+++ b/tests/io/stringio_with.py
@@ -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:
diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py
index 80f7f4416..9baac713e 100644
--- a/tests/misc/print_exception.py
+++ b/tests/misc/print_exception.py
@@ -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
-- 
GitLab