Skip to content

Commit

Permalink
tests: Replace umodule with module everywhere.
Browse files Browse the repository at this point in the history
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Jim Mussared committed Jun 8, 2023
1 parent 5e50975 commit 4216bc7
Showing 295 changed files with 1,009 additions and 1,431 deletions.
14 changes: 7 additions & 7 deletions ports/unix/coverage.c
Original file line number Diff line number Diff line change
@@ -356,19 +356,19 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf(&mp_plat_print, "# repl\n");

const char *str;
size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str); // expect "ame__"
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);

len = mp_repl_autocomplete("i", 1, &mp_plat_print, &str);
len = mp_repl_autocomplete("im", 2, &mp_plat_print, &str); // expect "port"
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str);
len = mp_repl_autocomplete("import ut", 9, &mp_plat_print, &str);
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str); // expect the list of builtins
len = mp_repl_autocomplete("import ti", 9, &mp_plat_print, &str); // expect "me"
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
mp_repl_autocomplete("import time", 12, &mp_plat_print, &str);
mp_repl_autocomplete("import time", 11, &mp_plat_print, &str); // expect "time timeq"

mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str);
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str);
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); // expect dir(sys)
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str); // expect "ementation"
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
}

9 changes: 3 additions & 6 deletions tests/basics/array1.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

a = array.array('B', [1, 2, 3])
print(a, len(a))
9 changes: 3 additions & 6 deletions tests/basics/array_add.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test array + array
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

a1 = array.array('I', [1])
a2 = array.array('I', [2])
9 changes: 3 additions & 6 deletions tests/basics/array_construct.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test construction of array.array from different objects

try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# tuple, list
print(array('b', (1, 2)))
9 changes: 3 additions & 6 deletions tests/basics/array_construct2.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# construct from something with unknown length (requires generators)
print(array('i', (i for i in range(10))))
9 changes: 3 additions & 6 deletions tests/basics/array_construct_endian.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test construction of array.array from different objects

try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# raw copy from bytes, bytearray
print(array('h', b'12'))
9 changes: 3 additions & 6 deletions tests/basics/array_intbig.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test array types QqLl that require big-ints

try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

print(array('L', [0, 2**32-1]))
print(array('l', [-2**31, 0, 2**31-1]))
9 changes: 3 additions & 6 deletions tests/basics/array_micropython.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test MicroPython-specific features of array.array
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# arrays of objects
a = array.array('O')
5 changes: 1 addition & 4 deletions tests/basics/async_await2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# test await expression

try:
import usys as sys
except ImportError:
import sys
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
5 changes: 1 addition & 4 deletions tests/basics/async_for2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# test waiting within "async for" __anext__ function

try:
import usys as sys
except ImportError:
import sys
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
5 changes: 1 addition & 4 deletions tests/basics/async_with2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# test waiting within async with enter/exit functions

try:
import usys as sys
except ImportError:
import sys
import sys
if sys.implementation.name == 'micropython':
# uPy allows normal generators to be awaitables
coroutine = lambda f: f
5 changes: 1 addition & 4 deletions tests/basics/attrtuple1.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# test attrtuple
# we can't test this type directly so we use sys.implementation object

try:
import usys as sys
except ImportError:
import sys
import sys
t = sys.implementation

# It can be just a normal tuple on small ports
5 changes: 1 addition & 4 deletions tests/basics/builtin_callable.py
Original file line number Diff line number Diff line change
@@ -7,10 +7,7 @@
print(callable("dfsd"))

# modules should not be callabe
try:
import usys as sys
except ImportError:
import sys
import sys
print(callable(sys))

# builtins should be callable
5 changes: 1 addition & 4 deletions tests/basics/builtin_dir.py
Original file line number Diff line number Diff line change
@@ -4,10 +4,7 @@
print('__name__' in dir())

# dir of module
try:
import usys as sys
except ImportError:
import sys
import sys
print('version' in dir(sys))

# dir of type
9 changes: 3 additions & 6 deletions tests/basics/bytearray_construct_array.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test construction of bytearray from different objects
try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# arrays
print(bytearray(array('b', [1, 2])))
9 changes: 3 additions & 6 deletions tests/basics/bytearray_construct_endian.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test construction of bytearray from different objects
try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# arrays
print(bytearray(array('h', [1, 2])))
9 changes: 3 additions & 6 deletions tests/basics/bytes_add_array.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test bytes + other
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# should be byteorder-neutral
print(b"123" + array.array('h', [0x1515]))
9 changes: 3 additions & 6 deletions tests/basics/bytes_add_endian.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# test bytes + other
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

print(b"123" + array.array('i', [1]))
9 changes: 3 additions & 6 deletions tests/basics/bytes_compare_array.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here
9 changes: 3 additions & 6 deletions tests/basics/bytes_construct_array.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# test construction of bytes from different objects
try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# arrays
print(bytes(array('b', [1, 2])))
9 changes: 3 additions & 6 deletions tests/basics/bytes_construct_endian.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test construction of bytes from different objects

try:
from uarray import array
from array import array
except ImportError:
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

# arrays
print(bytes(array('h', [1, 2])))
9 changes: 3 additions & 6 deletions tests/basics/class_ordereddict.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# test using an OrderedDict as the locals to construct a class

try:
from ucollections import OrderedDict
from collections import OrderedDict
except ImportError:
try:
from collections import OrderedDict
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

if not hasattr(int, "__dict__"):
print("SKIP")
7 changes: 2 additions & 5 deletions tests/basics/class_store_class.py
Original file line number Diff line number Diff line change
@@ -5,11 +5,8 @@
try:
from collections import namedtuple
except ImportError:
try:
from ucollections import namedtuple
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit

_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])

5 changes: 1 addition & 4 deletions tests/basics/deque1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
try:
try:
from ucollections import deque
except ImportError:
from collections import deque
from collections import deque
except ImportError:
print("SKIP")
raise SystemExit
5 changes: 1 addition & 4 deletions tests/basics/deque2.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Tests for deques with "check overflow" flag and other extensions
# wrt to CPython.
try:
try:
from ucollections import deque
except ImportError:
from collections import deque
from collections import deque
except ImportError:
print("SKIP")
raise SystemExit

0 comments on commit 4216bc7

Please sign in to comment.