tests: Replace umodule with module everywhere.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
5e50975a6d
commit
4216bc7d13
@ -356,19 +356,19 @@ STATIC mp_obj_t extra_coverage(void) {
|
|||||||
mp_printf(&mp_plat_print, "# repl\n");
|
mp_printf(&mp_plat_print, "# repl\n");
|
||||||
|
|
||||||
const char *str;
|
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);
|
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_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
||||||
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str);
|
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str); // expect the list of builtins
|
||||||
len = mp_repl_autocomplete("import ut", 9, &mp_plat_print, &str);
|
len = mp_repl_autocomplete("import ti", 9, &mp_plat_print, &str); // expect "me"
|
||||||
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
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_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);
|
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); // expect dir(sys)
|
||||||
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str);
|
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str); // expect "ementation"
|
||||||
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
a = array.array('B', [1, 2, 3])
|
a = array.array('B', [1, 2, 3])
|
||||||
print(a, len(a))
|
print(a, len(a))
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test array + array
|
# test array + array
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
a1 = array.array('I', [1])
|
a1 = array.array('I', [1])
|
||||||
a2 = array.array('I', [2])
|
a2 = array.array('I', [2])
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test construction of array.array from different objects
|
# test construction of array.array from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# tuple, list
|
# tuple, list
|
||||||
print(array('b', (1, 2)))
|
print(array('b', (1, 2)))
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# construct from something with unknown length (requires generators)
|
# construct from something with unknown length (requires generators)
|
||||||
print(array('i', (i for i in range(10))))
|
print(array('i', (i for i in range(10))))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test construction of array.array from different objects
|
# test construction of array.array from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# raw copy from bytes, bytearray
|
# raw copy from bytes, bytearray
|
||||||
print(array('h', b'12'))
|
print(array('h', b'12'))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test array types QqLl that require big-ints
|
# test array types QqLl that require big-ints
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(array('L', [0, 2**32-1]))
|
print(array('L', [0, 2**32-1]))
|
||||||
print(array('l', [-2**31, 0, 2**31-1]))
|
print(array('l', [-2**31, 0, 2**31-1]))
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test MicroPython-specific features of array.array
|
# test MicroPython-specific features of array.array
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# arrays of objects
|
# arrays of objects
|
||||||
a = array.array('O')
|
a = array.array('O')
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# test await expression
|
# test await expression
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# uPy allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# test waiting within "async for" __anext__ function
|
# test waiting within "async for" __anext__ function
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# uPy allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# test waiting within async with enter/exit functions
|
# test waiting within async with enter/exit functions
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
if sys.implementation.name == 'micropython':
|
if sys.implementation.name == 'micropython':
|
||||||
# uPy allows normal generators to be awaitables
|
# uPy allows normal generators to be awaitables
|
||||||
coroutine = lambda f: f
|
coroutine = lambda f: f
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# test attrtuple
|
# test attrtuple
|
||||||
# we can't test this type directly so we use sys.implementation object
|
# we can't test this type directly so we use sys.implementation object
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
t = sys.implementation
|
t = sys.implementation
|
||||||
|
|
||||||
# It can be just a normal tuple on small ports
|
# It can be just a normal tuple on small ports
|
||||||
|
@ -7,10 +7,7 @@ print(callable([]))
|
|||||||
print(callable("dfsd"))
|
print(callable("dfsd"))
|
||||||
|
|
||||||
# modules should not be callabe
|
# modules should not be callabe
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
print(callable(sys))
|
print(callable(sys))
|
||||||
|
|
||||||
# builtins should be callable
|
# builtins should be callable
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
print('__name__' in dir())
|
print('__name__' in dir())
|
||||||
|
|
||||||
# dir of module
|
# dir of module
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
print('version' in dir(sys))
|
print('version' in dir(sys))
|
||||||
|
|
||||||
# dir of type
|
# dir of type
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test construction of bytearray from different objects
|
# test construction of bytearray from different objects
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytearray(array('b', [1, 2])))
|
print(bytearray(array('b', [1, 2])))
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test construction of bytearray from different objects
|
# test construction of bytearray from different objects
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytearray(array('h', [1, 2])))
|
print(bytearray(array('h', [1, 2])))
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# should be byteorder-neutral
|
# should be byteorder-neutral
|
||||||
print(b"123" + array.array('h', [0x1515]))
|
print(b"123" + array.array('h', [0x1515]))
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(b"123" + array.array('i', [1]))
|
print(b"123" + array.array('i', [1]))
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
|
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
|
||||||
# CPython gives False here
|
# CPython gives False here
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
# test construction of bytes from different objects
|
# test construction of bytes from different objects
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytes(array('b', [1, 2])))
|
print(bytes(array('b', [1, 2])))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test construction of bytes from different objects
|
# test construction of bytes from different objects
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# arrays
|
# arrays
|
||||||
print(bytes(array('h', [1, 2])))
|
print(bytes(array('h', [1, 2])))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test using an OrderedDict as the locals to construct a class
|
# test using an OrderedDict as the locals to construct a class
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ucollections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from collections import OrderedDict
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
if not hasattr(int, "__dict__"):
|
if not hasattr(int, "__dict__"):
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
|
@ -5,11 +5,8 @@
|
|||||||
try:
|
try:
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from ucollections import namedtuple
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
|
_DefragResultBase = namedtuple('DefragResult', [ 'foo', 'bar' ])
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
from collections import deque
|
||||||
from ucollections import deque
|
|
||||||
except ImportError:
|
|
||||||
from collections import deque
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# Tests for deques with "check overflow" flag and other extensions
|
# Tests for deques with "check overflow" flag and other extensions
|
||||||
# wrt to CPython.
|
# wrt to CPython.
|
||||||
try:
|
try:
|
||||||
try:
|
from collections import deque
|
||||||
from ucollections import deque
|
|
||||||
except ImportError:
|
|
||||||
from collections import deque
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
# test that fixed dictionaries cannot be modified
|
# test that fixed dictionaries cannot be modified
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uerrno
|
import errno
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# Save a copy of uerrno.errorcode, so we can check later
|
# Save a copy of errno.errorcode, so we can check later
|
||||||
# that it hasn't been modified.
|
# that it hasn't been modified.
|
||||||
errorcode_copy = uerrno.errorcode.copy()
|
errorcode_copy = errno.errorcode.copy()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.popitem()
|
errno.errorcode.popitem()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.pop(0)
|
errno.errorcode.pop(0)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.setdefault(0, 0)
|
errno.errorcode.setdefault(0, 0)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.update([(1, 2)])
|
errno.errorcode.update([(1, 2)])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
del uerrno.errorcode[1]
|
del errno.errorcode[1]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode[1] = 'foo'
|
errno.errorcode[1] = 'foo'
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.clear()
|
errno.errorcode.clear()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
assert uerrno.errorcode == errorcode_copy
|
assert errno.errorcode == errorcode_copy
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
# test errno's and uerrno module
|
# test errno's and errno module
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uerrno
|
import errno
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# check that constants exist and are integers
|
# check that constants exist and are integers
|
||||||
print(type(uerrno.EIO))
|
print(type(errno.EIO))
|
||||||
|
|
||||||
# check that errors are rendered in a nice way
|
# check that errors are rendered in a nice way
|
||||||
msg = str(OSError(uerrno.EIO))
|
msg = str(OSError(errno.EIO))
|
||||||
print(msg[:7], msg[-5:])
|
print(msg[:7], msg[-5:])
|
||||||
msg = str(OSError(uerrno.EIO, "details"))
|
msg = str(OSError(errno.EIO, "details"))
|
||||||
print(msg[:7], msg[-14:])
|
print(msg[:7], msg[-14:])
|
||||||
msg = str(OSError(uerrno.EIO, "details", "more details"))
|
msg = str(OSError(errno.EIO, "details", "more details"))
|
||||||
print(msg[:1], msg[-28:])
|
print(msg[:1], msg[-28:])
|
||||||
|
|
||||||
# check that unknown errno is still rendered
|
# check that unknown errno is still rendered
|
||||||
print(str(OSError(9999)))
|
print(str(OSError(9999)))
|
||||||
|
|
||||||
# this tests a failed constant lookup in errno
|
# this tests a failed constant lookup in errno
|
||||||
errno = uerrno
|
errno = errno
|
||||||
print(errno.__name__)
|
print(errno.__name__)
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
[Errno ] EIO: details
|
[Errno ] EIO: details
|
||||||
( , 'details', 'more details')
|
( , 'details', 'more details')
|
||||||
9999
|
9999
|
||||||
uerrno
|
errno
|
||||||
|
@ -105,10 +105,7 @@ x = 4611686018427387904 # big
|
|||||||
x = -4611686018427387904 # big
|
x = -4611686018427387904 # big
|
||||||
|
|
||||||
# sys.maxsize is a constant mpz, so test it's compatible with dynamic ones
|
# sys.maxsize is a constant mpz, so test it's compatible with dynamic ones
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
print(sys.maxsize + 1 - 1 == sys.maxsize)
|
print(sys.maxsize + 1 - 1 == sys.maxsize)
|
||||||
|
|
||||||
# test extraction of big int value via mp_obj_get_int_maybe
|
# test extraction of big int value via mp_obj_get_int_maybe
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import uio as io
|
import io
|
||||||
|
|
||||||
try:
|
try:
|
||||||
io.BytesIO
|
io.BytesIO
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
# Make sure that write operations on io.BytesIO don't
|
# Make sure that write operations on io.BytesIO don't
|
||||||
# change original object it was constructed from.
|
# change original object it was constructed from.
|
||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
b = b"foobar"
|
b = b"foobar"
|
||||||
|
|
||||||
a = io.BytesIO(b)
|
a = io.BytesIO(b)
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
# Extended stream operations on io.BytesIO
|
# Extended stream operations on io.BytesIO
|
||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.BytesIO(b"foobar")
|
a = io.BytesIO(b"foobar")
|
||||||
a.seek(10)
|
a.seek(10)
|
||||||
print(a.read(10))
|
print(a.read(10))
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.BytesIO(b"foobar")
|
a = io.BytesIO(b"foobar")
|
||||||
try:
|
try:
|
||||||
a.seek(-10)
|
a.seek(-10)
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except:
|
|
||||||
import io
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
io.IOBase
|
io.IOBase
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
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))
|
||||||
print(a.getvalue())
|
print(a.getvalue())
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# Checks that an instance type inheriting from a native base that uses
|
# Checks that an instance type inheriting from a native base that uses
|
||||||
# MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter.
|
# MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter.
|
||||||
|
|
||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.StringIO()
|
a = io.StringIO()
|
||||||
a.write("hello\nworld\nmicro\npython\n")
|
a.write("hello\nworld\nmicro\npython\n")
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
# test __enter__/__exit__
|
# test __enter__/__exit__
|
||||||
with io.StringIO() as b:
|
with io.StringIO() as b:
|
||||||
b.write("foo")
|
b.write("foo")
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# This tests extended (MicroPython-specific) form of write:
|
# This tests extended (MicroPython-specific) form of write:
|
||||||
# write(buf, len) and write(buf, offset, len)
|
# write(buf, len) and write(buf, offset, len)
|
||||||
import uio
|
import io
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uio.BytesIO
|
io.BytesIO
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print('SKIP')
|
print('SKIP')
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
buf = uio.BytesIO()
|
buf = io.BytesIO()
|
||||||
|
|
||||||
buf.write(b"foo", 2)
|
buf.write(b"foo", 2)
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
|
@ -5,13 +5,10 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# test reading from bytes
|
# test reading from bytes
|
||||||
b = b'1234'
|
b = b'1234'
|
||||||
|
@ -5,13 +5,10 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(list(memoryview(b'\x7f\x80\x81\xff')))
|
print(list(memoryview(b'\x7f\x80\x81\xff')))
|
||||||
print(list(memoryview(array('b', [0x7f, -0x80]))))
|
print(list(memoryview(array('b', [0x7f, -0x80]))))
|
||||||
|
@ -5,13 +5,10 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
|
print(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
|
||||||
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))
|
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))
|
||||||
|
@ -4,13 +4,10 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
try:
|
try:
|
||||||
from uarray import array
|
from array import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from array import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
for code in ['b', 'h', 'i', 'q', 'f', 'd']:
|
for code in ['b', 'h', 'i', 'q', 'f', 'd']:
|
||||||
print(memoryview(array(code)).itemsize)
|
print(memoryview(array(code)).itemsize)
|
||||||
|
@ -7,13 +7,10 @@ except (NameError, TypeError):
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import array
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# test slice assignment between memoryviews
|
# test slice assignment between memoryviews
|
||||||
b1 = bytearray(b'1234')
|
b1 = bytearray(b'1234')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# uPy behaviour only: builtin modules are read-only
|
# uPy behaviour only: builtin modules are read-only
|
||||||
import usys
|
import sys
|
||||||
try:
|
try:
|
||||||
usys.x = 1
|
sys.x = 1
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print("AttributeError")
|
print("AttributeError")
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
from collections import namedtuple
|
||||||
from ucollections import namedtuple
|
|
||||||
except ImportError:
|
|
||||||
from collections import namedtuple
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
from collections import namedtuple
|
||||||
from ucollections import namedtuple
|
|
||||||
except ImportError:
|
|
||||||
from collections import namedtuple
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from ucollections import OrderedDict
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
|
d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
|
||||||
print(len(d))
|
print(len(d))
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
from ucollections import OrderedDict
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
x = OrderedDict()
|
x = OrderedDict()
|
||||||
y = OrderedDict()
|
y = OrderedDict()
|
||||||
|
@ -29,9 +29,9 @@ test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
|
|||||||
|
|
||||||
# from basics/sys1.py
|
# from basics/sys1.py
|
||||||
# uPy prints version 3.4
|
# uPy prints version 3.4
|
||||||
import usys
|
import sys
|
||||||
print(usys.version[:3])
|
print(sys.version[:3])
|
||||||
print(usys.version_info[0], usys.version_info[1])
|
print(sys.version_info[0], sys.version_info[1])
|
||||||
|
|
||||||
# from basics/exception1.py
|
# from basics/exception1.py
|
||||||
# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
|
# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
|
||||||
|
@ -51,10 +51,7 @@ print("1/" <= "1")
|
|||||||
|
|
||||||
# this tests an internal string that doesn't have a hash with a string
|
# this tests an internal string that doesn't have a hash with a string
|
||||||
# that does have a hash, but the lengths of the two strings are different
|
# that does have a hash, but the lengths of the two strings are different
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
print(sys.version == 'a long string that has a hash')
|
print(sys.version == 'a long string that has a hash')
|
||||||
|
|
||||||
# this special string would have a hash of 0 but is incremented to 1
|
# this special string would have a hash of 0 but is incremented to 1
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
import ustruct as struct
|
import struct
|
||||||
except:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import struct
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(struct.calcsize("<bI"))
|
print(struct.calcsize("<bI"))
|
||||||
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))
|
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
try:
|
try:
|
||||||
import ustruct as struct
|
import struct
|
||||||
except:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import struct
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# check maximum pack on 32-bit machine
|
# check maximum pack on 32-bit machine
|
||||||
print(struct.pack("<I", 2**32 - 1))
|
print(struct.pack("<I", 2**32 - 1))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test ustruct with a count specified before the type
|
# test struct with a count specified before the type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
import struct
|
||||||
except:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import struct
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
print(struct.calcsize('0s'))
|
print(struct.calcsize('0s'))
|
||||||
print(struct.unpack('0s', b''))
|
print(struct.unpack('0s', b''))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test ustruct and endian specific things
|
# test struct and endian specific things
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
import struct
|
||||||
except:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import struct
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# unpack/unpack_from with unaligned native type
|
# unpack/unpack_from with unaligned native type
|
||||||
buf = b'0123456789'
|
buf = b'0123456789'
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
# test MicroPython-specific features of struct
|
# test MicroPython-specific features of struct
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
import struct
|
||||||
except:
|
except ImportError:
|
||||||
try:
|
print("SKIP")
|
||||||
import struct
|
raise SystemExit
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
class A():
|
class A():
|
||||||
pass
|
pass
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
# and is callable (has call). The only one available is machine.Signal, which
|
# and is callable (has call). The only one available is machine.Signal, which
|
||||||
# in turns needs PinBase.
|
# in turns needs PinBase.
|
||||||
try:
|
try:
|
||||||
try:
|
import machine
|
||||||
import umachine as machine
|
|
||||||
except ImportError:
|
|
||||||
import machine
|
|
||||||
machine.PinBase
|
machine.PinBase
|
||||||
machine.Signal
|
machine.Signal
|
||||||
except:
|
except:
|
||||||
|
@ -29,7 +29,6 @@ except Exception as bad:
|
|||||||
print(type(bad), bad.args[0])
|
print(type(bad), bad.args[0])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
# test sys module
|
# test sys module
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
|
|
||||||
print(sys.__name__)
|
print(sys.__name__)
|
||||||
print(type(sys.path))
|
print(type(sys.path))
|
||||||
print(type(sys.argv))
|
print(type(sys.argv))
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
# test sys module's exit function
|
# test sys module's exit function
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.exit
|
sys.exit
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# test sys.getsizeof() function
|
# test sys.getsizeof() function
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
try:
|
try:
|
||||||
sys.getsizeof
|
sys.getsizeof
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -19,7 +16,7 @@ print(sys.getsizeof(A()) > 0)
|
|||||||
|
|
||||||
# Only test deque if we have it
|
# Only test deque if we have it
|
||||||
try:
|
try:
|
||||||
from ucollections import deque
|
from collections import deque
|
||||||
assert sys.getsizeof(deque((), 1)) > 0
|
assert sys.getsizeof(deque((), 1)) > 0
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
# test sys.path
|
# test sys.path
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# check that this script was executed from a file of the same name
|
# check that this script was executed from a file of the same name
|
||||||
if "__file__" not in globals() or "sys_path.py" not in __file__:
|
if "__file__" not in globals() or "sys_path.py" not in __file__:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
# test sys.tracebacklimit
|
# test sys.tracebacklimit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
import io
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
File , line 49, in f1
|
File , line 45, in f1
|
||||||
File , line 45, in f0
|
File , line 41, in f0
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 4
|
limit 4
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
File , line 49, in f1
|
File , line 45, in f1
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 3
|
limit 3
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 2
|
limit 2
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 1
|
limit 1
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 0
|
limit 0
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import uos
|
import os
|
||||||
|
|
||||||
uos.putenv('MICROPYINSPECT', '1')
|
os.putenv('MICROPYINSPECT', '1')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# test changing ps1/ps2
|
# test changing ps1/ps2
|
||||||
import usys
|
import sys
|
||||||
usys.ps1 = "PS1"
|
sys.ps1 = "PS1"
|
||||||
usys.ps2 = "PS2"
|
sys.ps2 = "PS2"
|
||||||
(1 +
|
(1 +
|
||||||
2)
|
2)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
MicroPython \.\+ version
|
MicroPython \.\+ version
|
||||||
Use \.\+
|
Use \.\+
|
||||||
>>> # test changing ps1/ps2
|
>>> # test changing ps1/ps2
|
||||||
>>> import usys
|
>>> import sys
|
||||||
>>> usys.ps1 = "PS1"
|
>>> sys.ps1 = "PS1"
|
||||||
PS1usys.ps2 = "PS2"
|
PS1sys.ps2 = "PS2"
|
||||||
PS1(1 +
|
PS1(1 +
|
||||||
PS22)
|
PS22)
|
||||||
3
|
3
|
||||||
|
@ -22,10 +22,10 @@ def log(*args):
|
|||||||
|
|
||||||
|
|
||||||
# replace boot.py with the test code that will run on each reboot
|
# replace boot.py with the test code that will run on each reboot
|
||||||
import uos
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uos.rename("boot.py", "boot-orig.py")
|
os.rename("boot.py", "boot-orig.py")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
with open("boot.py", "w") as f:
|
with open("boot.py", "w") as f:
|
||||||
@ -74,10 +74,10 @@ elif STEP == 3:
|
|||||||
elif STEP == 4:
|
elif STEP == 4:
|
||||||
log("Confirming boot ok and DONE!")
|
log("Confirming boot ok and DONE!")
|
||||||
Partition.mark_app_valid_cancel_rollback()
|
Partition.mark_app_valid_cancel_rollback()
|
||||||
import uos
|
import os
|
||||||
uos.remove("step.py")
|
os.remove("step.py")
|
||||||
uos.remove("boot.py")
|
os.remove("boot.py")
|
||||||
uos.rename("boot-orig.py", "boot.py")
|
os.rename("boot-orig.py", "boot.py")
|
||||||
print("\\nSUCCESS!\\n\\x04\\x04")
|
print("\\nSUCCESS!\\n\\x04\\x04")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -5,10 +5,7 @@ if sys.implementation.name == "micropython" and sys.platform != "esp32":
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
import socket, sys
|
||||||
import usocket as socket, sys
|
|
||||||
except:
|
|
||||||
import socket, sys
|
|
||||||
|
|
||||||
|
|
||||||
def test_bind_resolves_0_0_0_0():
|
def test_bind_resolves_0_0_0_0():
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
import binascii
|
||||||
import ubinascii as binascii
|
|
||||||
except ImportError:
|
|
||||||
import binascii
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
import binascii
|
||||||
import ubinascii as binascii
|
|
||||||
except ImportError:
|
|
||||||
import binascii
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
import binascii
|
||||||
import ubinascii as binascii
|
|
||||||
except ImportError:
|
|
||||||
import binascii
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
import binascii
|
||||||
import ubinascii as binascii
|
|
||||||
except ImportError:
|
|
||||||
import binascii
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,8 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
try:
|
import binascii
|
||||||
import ubinascii as binascii
|
|
||||||
except ImportError:
|
|
||||||
import binascii
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,13 +1,13 @@
|
|||||||
try:
|
try:
|
||||||
import btree
|
import btree
|
||||||
import uio
|
import io
|
||||||
import uerrno
|
import errno
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# f = open("_test.db", "w+b")
|
# f = open("_test.db", "w+b")
|
||||||
f = uio.BytesIO()
|
f = io.BytesIO()
|
||||||
db = btree.open(f, pagesize=512)
|
db = btree.open(f, pagesize=512)
|
||||||
|
|
||||||
mv = memoryview(b"bar1foo1")
|
mv = memoryview(b"bar1foo1")
|
||||||
@ -68,7 +68,7 @@ print(db.seq(1, b"qux"))
|
|||||||
try:
|
try:
|
||||||
db.seq(b"foo1")
|
db.seq(b"foo1")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print(e.errno == uerrno.EINVAL)
|
print(e.errno == errno.EINVAL)
|
||||||
|
|
||||||
print(list(db.keys()))
|
print(list(db.keys()))
|
||||||
print(list(db.values()))
|
print(list(db.values()))
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
# Test that errno's propagate correctly through btree module.
|
# Test that errno's propagate correctly through btree module.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import btree, uio, uerrno
|
import btree, io, errno
|
||||||
|
|
||||||
uio.IOBase
|
io.IOBase
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|
||||||
class Device(uio.IOBase):
|
class Device(io.IOBase):
|
||||||
def __init__(self, read_ret=0, ioctl_ret=0):
|
def __init__(self, read_ret=0, ioctl_ret=0):
|
||||||
self.read_ret = read_ret
|
self.read_ret = read_ret
|
||||||
self.ioctl_ret = ioctl_ret
|
self.ioctl_ret = ioctl_ret
|
||||||
@ -25,18 +25,24 @@ class Device(uio.IOBase):
|
|||||||
|
|
||||||
# Invalid pagesize; errno comes from btree library
|
# Invalid pagesize; errno comes from btree library
|
||||||
try:
|
try:
|
||||||
|
import btree, io, errno
|
||||||
|
|
||||||
db = btree.open(Device(), pagesize=511)
|
db = btree.open(Device(), pagesize=511)
|
||||||
except OSError as er:
|
except OSError as er:
|
||||||
print("OSError", er.errno == uerrno.EINVAL)
|
print("OSError", er.errno == errno.EINVAL)
|
||||||
|
|
||||||
# Valid pagesize, device returns error on read; errno comes from Device.readinto
|
# Valid pagesize, device returns error on read; errno comes from Device.readinto
|
||||||
try:
|
try:
|
||||||
|
import btree, io, errno
|
||||||
|
|
||||||
db = btree.open(Device(-1000), pagesize=512)
|
db = btree.open(Device(-1000), pagesize=512)
|
||||||
except OSError as er:
|
except OSError as er:
|
||||||
print(repr(er))
|
print(repr(er))
|
||||||
|
|
||||||
# Valid pagesize, device returns error on seek; errno comes from Device.ioctl
|
# Valid pagesize, device returns error on seek; errno comes from Device.ioctl
|
||||||
try:
|
try:
|
||||||
|
import btree, io, errno
|
||||||
|
|
||||||
db = btree.open(Device(0, -1001), pagesize=512)
|
db = btree.open(Device(0, -1001), pagesize=512)
|
||||||
except OSError as er:
|
except OSError as er:
|
||||||
print(repr(er))
|
print(repr(er))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Test btree interaction with the garbage collector.
|
# Test btree interaction with the garbage collector.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import btree, uio, gc
|
import btree, io, gc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@ -9,7 +9,7 @@ except ImportError:
|
|||||||
N = 80
|
N = 80
|
||||||
|
|
||||||
# Create a BytesIO but don't keep a reference to it.
|
# Create a BytesIO but don't keep a reference to it.
|
||||||
db = btree.open(uio.BytesIO(), pagesize=512)
|
db = btree.open(io.BytesIO(), pagesize=512)
|
||||||
|
|
||||||
# Overwrite lots of the Python stack to make sure no reference to the BytesIO remains.
|
# Overwrite lots of the Python stack to make sure no reference to the BytesIO remains.
|
||||||
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
@ -4,7 +4,7 @@ try:
|
|||||||
aes = AES.new
|
aes = AES.new
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,5 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -4,7 +4,7 @@ try:
|
|||||||
aes = AES.new
|
aes = AES.new
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -7,7 +7,7 @@ try:
|
|||||||
aes = AES.new
|
aes = AES.new
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,6 +1,6 @@
|
|||||||
# Inplace operations (input and output buffer is the same)
|
# Inplace operations (input and output buffer is the same)
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,6 +1,6 @@
|
|||||||
# Operations with pre-allocated output buffer
|
# Operations with pre-allocated output buffer
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -4,7 +4,7 @@ try:
|
|||||||
aes = AES.new
|
aes = AES.new
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -4,7 +4,7 @@ try:
|
|||||||
aes = AES.new
|
aes = AES.new
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ucryptolib import aes
|
from cryptolib import aes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
@ -1,11 +1,11 @@
|
|||||||
try:
|
try:
|
||||||
import framebuf, usys
|
import framebuf, sys
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# This test and its .exp file is based on a little-endian architecture.
|
# This test and its .exp file is based on a little-endian architecture.
|
||||||
if usys.byteorder != "little":
|
if sys.byteorder != "little":
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Test blit between different color spaces
|
# Test blit between different color spaces
|
||||||
try:
|
try:
|
||||||
import framebuf, usys
|
import framebuf, sys
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# test subclassing framebuf.FrameBuffer
|
# test subclassing framebuf.FrameBuffer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import framebuf, usys
|
import framebuf, sys
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# This test and its .exp file is based on a little-endian architecture.
|
# This test and its .exp file is based on a little-endian architecture.
|
||||||
if usys.byteorder != "little":
|
if sys.byteorder != "little":
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
try:
|
try:
|
||||||
import uhashlib
|
import hashlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|
||||||
for algo_name in ("md5", "sha1", "sha256"):
|
for algo_name in ("md5", "sha1", "sha256"):
|
||||||
algo = getattr(uhashlib, algo_name, None)
|
algo = getattr(hashlib, algo_name, None)
|
||||||
if not algo:
|
if not algo:
|
||||||
continue
|
continue
|
||||||
|
|
18
tests/extmod/hashlib_md5.py
Normal file
18
tests/extmod/hashlib_md5.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
try:
|
||||||
|
import hashlib
|
||||||
|
except ImportError:
|
||||||
|
# This is neither uPy, nor cPy, so must be uPy with
|
||||||
|
# hashlib module disabled.
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
try:
|
||||||
|
hashlib.md5
|
||||||
|
except AttributeError:
|
||||||
|
# MD5 is only available on some ports
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
md5 = hashlib.md5(b"hello")
|
||||||
|
md5.update(b"world")
|
||||||
|
print(md5.digest())
|
18
tests/extmod/hashlib_sha1.py
Normal file
18
tests/extmod/hashlib_sha1.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
try:
|
||||||
|
import hashlib
|
||||||
|
except ImportError:
|
||||||
|
# This is neither uPy, nor cPy, so must be uPy with
|
||||||
|
# hashlib module disabled.
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
try:
|
||||||
|
hashlib.sha1
|
||||||
|
except AttributeError:
|
||||||
|
# SHA1 is only available on some ports
|
||||||
|
print("SKIP")
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
sha1 = hashlib.sha1(b"hello")
|
||||||
|
sha1.update(b"world")
|
||||||
|
print(sha1.digest())
|
@ -1,13 +1,10 @@
|
|||||||
try:
|
try:
|
||||||
import uhashlib as hashlib
|
import hashlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
# This is neither uPy, nor cPy, so must be uPy with
|
||||||
import hashlib
|
# hashlib module disabled.
|
||||||
except ImportError:
|
print("SKIP")
|
||||||
# This is neither uPy, nor cPy, so must be uPy with
|
raise SystemExit
|
||||||
# uhashlib module disabled.
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
h = hashlib.sha256()
|
h = hashlib.sha256()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user