summaryrefslogtreecommitdiff
path: root/tests/micropython
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-08-18 16:57:45 +1000
committerJim Mussared <jim.mussared@gmail.com>2023-06-08 17:54:24 +1000
commit4216bc7d1351feb8199e4ebbff1a9598aa1c5b02 (patch)
tree5085738ef65ab377c221f290c7fa90ec2acd4d29 /tests/micropython
parent5e50975a6dd9466afafbcd012c00078093fe1f57 (diff)
tests: Replace umodule with module everywhere.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/micropython')
-rw-r--r--tests/micropython/builtin_execfile.py22
-rw-r--r--tests/micropython/emg_exc.py8
-rw-r--r--tests/micropython/heapalloc_bytesio.py4
-rw-r--r--tests/micropython/heapalloc_bytesio2.py4
-rw-r--r--tests/micropython/heapalloc_iter.py9
-rw-r--r--tests/micropython/heapalloc_traceback.py8
-rw-r--r--tests/micropython/import_mpy_invalid.py16
-rw-r--r--tests/micropython/import_mpy_native.py20
-rw-r--r--tests/micropython/import_mpy_native_gc.py12
-rw-r--r--tests/micropython/opt_level_lineno.py2
-rw-r--r--tests/micropython/viper_misc_intbig.py4
11 files changed, 55 insertions, 54 deletions
diff --git a/tests/micropython/builtin_execfile.py b/tests/micropython/builtin_execfile.py
index 8a8ce79f7..5a26ccf0a 100644
--- a/tests/micropython/builtin_execfile.py
+++ b/tests/micropython/builtin_execfile.py
@@ -1,17 +1,17 @@
# Test builtin execfile function using VFS.
try:
- import uio, uos
+ import io, os
execfile
- uio.IOBase
- uos.mount
+ io.IOBase
+ os.mount
except (ImportError, NameError, AttributeError):
print("SKIP")
raise SystemExit
-class File(uio.IOBase):
+class File(io.IOBase):
def __init__(self, data):
self.data = data
self.off = 0
@@ -44,21 +44,25 @@ class Filesystem:
# First umount any existing mount points the target may have.
try:
- uos.umount("/")
+ import io, os
+
+ os.umount("/")
except OSError:
pass
-for path in uos.listdir("/"):
- uos.umount("/" + path)
+for path in os.listdir("/"):
+ os.umount("/" + path)
# Create and mount the VFS object.
files = {
"/test.py": "print(123)",
}
fs = Filesystem(files)
-uos.mount(fs, "/test_mnt")
+os.mount(fs, "/test_mnt")
# Test execfile with a file that doesn't exist.
try:
+ import io, os
+
execfile("/test_mnt/noexist.py")
except OSError:
print("OSError")
@@ -67,4 +71,4 @@ except OSError:
execfile("/test_mnt/test.py")
# Unmount the VFS object.
-uos.umount(fs)
+os.umount(fs)
diff --git a/tests/micropython/emg_exc.py b/tests/micropython/emg_exc.py
index b8df94b07..9a09956c8 100644
--- a/tests/micropython/emg_exc.py
+++ b/tests/micropython/emg_exc.py
@@ -1,10 +1,10 @@
# test that emergency exceptions work
import micropython
-import usys
+import sys
try:
- import uio
+ import io
except ImportError:
print("SKIP")
raise SystemExit
@@ -25,8 +25,8 @@ def f():
micropython.heap_unlock()
# print the exception
- buf = uio.StringIO()
- usys.print_exception(exc, buf)
+ buf = io.StringIO()
+ sys.print_exception(exc, buf)
for l in buf.getvalue().split("\n"):
if l.startswith(" File "):
print(l.split('"')[2])
diff --git a/tests/micropython/heapalloc_bytesio.py b/tests/micropython/heapalloc_bytesio.py
index 4aae2abf0..0ac8c9255 100644
--- a/tests/micropython/heapalloc_bytesio.py
+++ b/tests/micropython/heapalloc_bytesio.py
@@ -1,5 +1,5 @@
try:
- import uio
+ import io
except ImportError:
print("SKIP")
raise SystemExit
@@ -7,7 +7,7 @@ except ImportError:
import micropython
data = b"1234" * 16
-buf = uio.BytesIO(64)
+buf = io.BytesIO(64)
micropython.heap_lock()
diff --git a/tests/micropython/heapalloc_bytesio2.py b/tests/micropython/heapalloc_bytesio2.py
index 3b9f14127..05c384a51 100644
--- a/tests/micropython/heapalloc_bytesio2.py
+++ b/tests/micropython/heapalloc_bytesio2.py
@@ -1,7 +1,7 @@
# Creating BytesIO from immutable object should not immediately
# copy its content.
try:
- import uio
+ import io
import micropython
micropython.mem_total
@@ -14,7 +14,7 @@ data = b"1234" * 256
before = micropython.mem_total()
-buf = uio.BytesIO(data)
+buf = io.BytesIO(data)
after = micropython.mem_total()
diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py
index 18f5322ee..bd1ba4db7 100644
--- a/tests/micropython/heapalloc_iter.py
+++ b/tests/micropython/heapalloc_iter.py
@@ -5,13 +5,10 @@ except NameError:
print("SKIP")
raise SystemExit
try:
- import uarray as array
+ import array
except ImportError:
- try:
- import array
- except ImportError:
- print("SKIP")
- raise SystemExit
+ print("SKIP")
+ raise SystemExit
try:
from micropython import heap_lock, heap_unlock
diff --git a/tests/micropython/heapalloc_traceback.py b/tests/micropython/heapalloc_traceback.py
index 09a2ad2c1..4c5f99afe 100644
--- a/tests/micropython/heapalloc_traceback.py
+++ b/tests/micropython/heapalloc_traceback.py
@@ -1,10 +1,10 @@
# test that we can generate a traceback without allocating
import micropython
-import usys
+import sys
try:
- import uio
+ import io
except ImportError:
print("SKIP")
raise SystemExit
@@ -32,8 +32,8 @@ def test():
test()
# print the exception that was raised
-buf = uio.StringIO()
-usys.print_exception(global_exc, buf)
+buf = io.StringIO()
+sys.print_exception(global_exc, buf)
for l in buf.getvalue().split("\n"):
# uPy on pyboard prints <stdin> as file, so remove filename.
if l.startswith(" File "):
diff --git a/tests/micropython/import_mpy_invalid.py b/tests/micropython/import_mpy_invalid.py
index b02312a7a..36db102e9 100644
--- a/tests/micropython/import_mpy_invalid.py
+++ b/tests/micropython/import_mpy_invalid.py
@@ -1,16 +1,16 @@
# test importing of invalid .mpy files
try:
- import usys, uio, uos
+ import sys, io, os
- uio.IOBase
- uos.mount
+ io.IOBase
+ os.mount
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
-class UserFile(uio.IOBase):
+class UserFile(io.IOBase):
def __init__(self, data):
self.data = memoryview(data)
self.pos = 0
@@ -52,8 +52,8 @@ user_files = {
}
# create and mount a user filesystem
-uos.mount(UserFS(user_files), "/userfs")
-usys.path.append("/userfs")
+os.mount(UserFS(user_files), "/userfs")
+sys.path.append("/userfs")
# import .mpy files from the user filesystem
for i in range(len(user_files)):
@@ -64,5 +64,5 @@ for i in range(len(user_files)):
print(mod, "ValueError", er)
# unmount and undo path addition
-uos.umount("/userfs")
-usys.path.pop()
+os.umount("/userfs")
+sys.path.pop()
diff --git a/tests/micropython/import_mpy_native.py b/tests/micropython/import_mpy_native.py
index 73e20694c..da20746b2 100644
--- a/tests/micropython/import_mpy_native.py
+++ b/tests/micropython/import_mpy_native.py
@@ -1,23 +1,23 @@
# test importing of .mpy files with native code
try:
- import usys, uio, uos
+ import sys, io, os
- usys.implementation._mpy
- uio.IOBase
- uos.mount
+ sys.implementation._mpy
+ io.IOBase
+ os.mount
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
-mpy_arch = usys.implementation._mpy >> 8
+mpy_arch = sys.implementation._mpy >> 8
if mpy_arch >> 2 == 0:
# This system does not support .mpy files containing native code
print("SKIP")
raise SystemExit
-class UserFile(uio.IOBase):
+class UserFile(io.IOBase):
def __init__(self, data):
self.data = memoryview(data)
self.pos = 0
@@ -110,8 +110,8 @@ user_files = {
# fmt: on
# create and mount a user filesystem
-uos.mount(UserFS(user_files), "/userfs")
-usys.path.append("/userfs")
+os.mount(UserFS(user_files), "/userfs")
+sys.path.append("/userfs")
# import .mpy files from the user filesystem
for i in range(len(user_files)):
@@ -123,5 +123,5 @@ for i in range(len(user_files)):
print(mod, "ValueError", er)
# unmount and undo path addition
-uos.umount("/userfs")
-usys.path.pop()
+os.umount("/userfs")
+sys.path.pop()
diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py
index e18720fb3..5a3855dc7 100644
--- a/tests/micropython/import_mpy_native_gc.py
+++ b/tests/micropython/import_mpy_native_gc.py
@@ -1,17 +1,17 @@
# Test that native code loaded from a .mpy file is retained after a GC.
try:
- import gc, sys, uio, uos
+ import gc, sys, io, os
sys.implementation._mpy
- uio.IOBase
- uos.mount
+ io.IOBase
+ os.mount
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
-class UserFile(uio.IOBase):
+class UserFile(io.IOBase):
def __init__(self, data):
self.data = memoryview(data)
self.pos = 0
@@ -68,7 +68,7 @@ if sys_implementation_mpy not in features0_file_contents:
user_files = {"/features0.mpy": features0_file_contents[sys_implementation_mpy]}
# Create and mount a user filesystem.
-uos.mount(UserFS(user_files), "/userfs")
+os.mount(UserFS(user_files), "/userfs")
sys.path.append("/userfs")
# Import the native function.
@@ -89,5 +89,5 @@ for i in range(1000):
print(factorial(10))
# Unmount and undo path addition.
-uos.umount("/userfs")
+os.umount("/userfs")
sys.path.pop()
diff --git a/tests/micropython/opt_level_lineno.py b/tests/micropython/opt_level_lineno.py
index 1cbf2fb1a..d8253e54b 100644
--- a/tests/micropython/opt_level_lineno.py
+++ b/tests/micropython/opt_level_lineno.py
@@ -3,4 +3,4 @@ import micropython as micropython
# check that level 3 doesn't store line numbers
# the expected output is that any line is printed as "line 1"
micropython.opt_level(3)
-exec("try:\n xyz\nexcept NameError as er:\n import usys\n usys.print_exception(er)")
+exec("try:\n xyz\nexcept NameError as er:\n import sys\n sys.print_exception(er)")
diff --git a/tests/micropython/viper_misc_intbig.py b/tests/micropython/viper_misc_intbig.py
index ac09f5785..91673f2c1 100644
--- a/tests/micropython/viper_misc_intbig.py
+++ b/tests/micropython/viper_misc_intbig.py
@@ -7,6 +7,6 @@ def viper_uint() -> uint:
return uint(-1)
-import usys
+import sys
-print(viper_uint() == (usys.maxsize << 1 | 1))
+print(viper_uint() == (sys.maxsize << 1 | 1))