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:
Jim Mussared 2022-08-18 16:57:45 +10:00
parent 5e50975a6d
commit 4216bc7d13
295 changed files with 1006 additions and 1428 deletions

View File

@ -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);
}

View File

@ -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))

View File

@ -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])

View File

@ -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)))

View File

@ -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))))

View File

@ -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'))

View File

@ -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]))

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -7,10 +7,7 @@ print(callable([]))
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

View File

@ -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

View File

@ -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])))

View File

@ -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])))

View File

@ -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]))

View File

@ -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]))

View File

@ -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

View File

@ -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])))

View File

@ -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])))

View File

@ -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")

View File

@ -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' ])

View File

@ -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

View File

@ -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

View File

@ -1,48 +1,48 @@
# test that fixed dictionaries cannot be modified
try:
import uerrno
import errno
except ImportError:
print("SKIP")
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.
errorcode_copy = uerrno.errorcode.copy()
errorcode_copy = errno.errorcode.copy()
try:
uerrno.errorcode.popitem()
errno.errorcode.popitem()
except TypeError:
print("TypeError")
try:
uerrno.errorcode.pop(0)
errno.errorcode.pop(0)
except TypeError:
print("TypeError")
try:
uerrno.errorcode.setdefault(0, 0)
errno.errorcode.setdefault(0, 0)
except TypeError:
print("TypeError")
try:
uerrno.errorcode.update([(1, 2)])
errno.errorcode.update([(1, 2)])
except TypeError:
print("TypeError")
try:
del uerrno.errorcode[1]
del errno.errorcode[1]
except TypeError:
print("TypeError")
try:
uerrno.errorcode[1] = 'foo'
errno.errorcode[1] = 'foo'
except TypeError:
print("TypeError")
try:
uerrno.errorcode.clear()
errno.errorcode.clear()
except TypeError:
print("TypeError")
assert uerrno.errorcode == errorcode_copy
assert errno.errorcode == errorcode_copy

View File

@ -1,25 +1,25 @@
# test errno's and uerrno module
# test errno's and errno module
try:
import uerrno
import errno
except ImportError:
print("SKIP")
raise SystemExit
# check that constants exist and are integers
print(type(uerrno.EIO))
print(type(errno.EIO))
# check that errors are rendered in a nice way
msg = str(OSError(uerrno.EIO))
msg = str(OSError(errno.EIO))
print(msg[:7], msg[-5:])
msg = str(OSError(uerrno.EIO, "details"))
msg = str(OSError(errno.EIO, "details"))
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:])
# check that unknown errno is still rendered
print(str(OSError(9999)))
# this tests a failed constant lookup in errno
errno = uerrno
errno = errno
print(errno.__name__)

View File

@ -3,4 +3,4 @@
[Errno ] EIO: details
( , 'details', 'more details')
9999
uerrno
errno

View File

@ -105,10 +105,7 @@ x = 4611686018427387904 # big
x = -4611686018427387904 # big
# sys.maxsize is a constant mpz, so test it's compatible with dynamic ones
try:
import usys as sys
except ImportError:
import sys
import sys
print(sys.maxsize + 1 - 1 == sys.maxsize)
# test extraction of big int value via mp_obj_get_int_maybe

View File

@ -1,4 +1,4 @@
import uio as io
import io
try:
io.BytesIO

View File

@ -1,10 +1,6 @@
# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.
try:
import uio as io
except ImportError:
import io
import io
b = b"foobar"
a = io.BytesIO(b)

View File

@ -1,9 +1,5 @@
# Extended stream operations on io.BytesIO
try:
import uio as io
except ImportError:
import io
import io
a = io.BytesIO(b"foobar")
a.seek(10)
print(a.read(10))

View File

@ -1,8 +1,4 @@
try:
import uio as io
except ImportError:
import io
import io
a = io.BytesIO(b"foobar")
try:
a.seek(-10)

View File

@ -1,8 +1,4 @@
try:
import uio as io
except:
import io
import io
try:
io.IOBase
except AttributeError:

View File

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

View File

@ -1,10 +1,7 @@
# Checks that an instance type inheriting from a native base that uses
# MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter.
try:
import uio as io
except ImportError:
import io
import io
a = io.StringIO()
a.write("hello\nworld\nmicro\npython\n")

View File

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

View File

@ -1,14 +1,14 @@
# This tests extended (MicroPython-specific) form of write:
# write(buf, len) and write(buf, offset, len)
import uio
import io
try:
uio.BytesIO
io.BytesIO
except AttributeError:
print('SKIP')
raise SystemExit
buf = uio.BytesIO()
buf = io.BytesIO()
buf.write(b"foo", 2)
print(buf.getvalue())

View File

@ -5,13 +5,10 @@ except:
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
# test reading from bytes
b = b'1234'

View File

@ -5,13 +5,10 @@ except:
print("SKIP")
raise SystemExit
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(list(memoryview(b'\x7f\x80\x81\xff')))
print(list(memoryview(array('b', [0x7f, -0x80]))))

View File

@ -5,13 +5,10 @@ except:
print("SKIP")
raise SystemExit
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(list(memoryview(array('i', [0x7f000000, -0x80000000]))))
print(list(memoryview(array('I', [0x7f000000, 0x80000000, 0x81000000, 0xffffffff]))))

View File

@ -4,13 +4,10 @@ except:
print("SKIP")
raise SystemExit
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
for code in ['b', 'h', 'i', 'q', 'f', 'd']:
print(memoryview(array(code)).itemsize)

View File

@ -7,13 +7,10 @@ except (NameError, TypeError):
raise SystemExit
try:
import uarray as array
import array
except ImportError:
try:
import array
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit
# test slice assignment between memoryviews
b1 = bytearray(b'1234')

View File

@ -1,6 +1,6 @@
# uPy behaviour only: builtin modules are read-only
import usys
import sys
try:
usys.x = 1
sys.x = 1
except AttributeError:
print("AttributeError")

View File

@ -1,8 +1,5 @@
try:
try:
from ucollections import namedtuple
except ImportError:
from collections import namedtuple
from collections import namedtuple
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,8 +1,5 @@
try:
try:
from ucollections import namedtuple
except ImportError:
from collections import namedtuple
from collections import namedtuple
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,11 +1,8 @@
try:
from collections import OrderedDict
except ImportError:
try:
from ucollections import OrderedDict
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit
d = OrderedDict([(10, 20), ("b", 100), (1, 2)])
print(len(d))

View File

@ -1,11 +1,8 @@
try:
from collections import OrderedDict
except ImportError:
try:
from ucollections import OrderedDict
except ImportError:
print("SKIP")
raise SystemExit
print("SKIP")
raise SystemExit
x = OrderedDict()
y = OrderedDict()

View File

@ -29,9 +29,9 @@ test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
# from basics/sys1.py
# uPy prints version 3.4
import usys
print(usys.version[:3])
print(usys.version_info[0], usys.version_info[1])
import sys
print(sys.version[:3])
print(sys.version_info[0], sys.version_info[1])
# 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)

View File

@ -51,10 +51,7 @@ print("1/" <= "1")
# 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
try:
import usys as sys
except ImportError:
import sys
import sys
print(sys.version == 'a long string that has a hash')
# this special string would have a hash of 0 but is incremented to 1

View File

@ -1,11 +1,8 @@
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
import struct
except ImportError:
print("SKIP")
raise SystemExit
print(struct.calcsize("<bI"))
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))

View File

@ -1,11 +1,8 @@
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
import struct
except ImportError:
print("SKIP")
raise SystemExit
# check maximum pack on 32-bit machine
print(struct.pack("<I", 2**32 - 1))

View File

@ -1,13 +1,10 @@
# test ustruct with a count specified before the type
# test struct with a count specified before the type
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
import struct
except ImportError:
print("SKIP")
raise SystemExit
print(struct.calcsize('0s'))
print(struct.unpack('0s', b''))

View File

@ -1,13 +1,10 @@
# test ustruct and endian specific things
# test struct and endian specific things
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
import struct
except ImportError:
print("SKIP")
raise SystemExit
# unpack/unpack_from with unaligned native type
buf = b'0123456789'

View File

@ -1,13 +1,10 @@
# test MicroPython-specific features of struct
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
import struct
except ImportError:
print("SKIP")
raise SystemExit
class A():
pass

View File

@ -4,10 +4,7 @@
# and is callable (has call). The only one available is machine.Signal, which
# in turns needs PinBase.
try:
try:
import umachine as machine
except ImportError:
import machine
import machine
machine.PinBase
machine.Signal
except:

View File

@ -29,7 +29,6 @@ except Exception as bad:
print(type(bad), bad.args[0])
try:
def gen():
yield

View File

@ -1,10 +1,6 @@
# test sys module
try:
import usys as sys
except ImportError:
import sys
import sys
print(sys.__name__)
print(type(sys.path))
print(type(sys.argv))

View File

@ -1,10 +1,6 @@
# test sys module's exit function
try:
import usys as sys
except ImportError:
import sys
import sys
try:
sys.exit
except AttributeError:

View File

@ -1,9 +1,6 @@
# test sys.getsizeof() function
try:
import usys as sys
except ImportError:
import sys
import sys
try:
sys.getsizeof
except AttributeError:
@ -19,7 +16,7 @@ print(sys.getsizeof(A()) > 0)
# Only test deque if we have it
try:
from ucollections import deque
from collections import deque
assert sys.getsizeof(deque((), 1)) > 0
except ImportError:
pass

View File

@ -1,10 +1,6 @@
# test sys.path
try:
import usys as sys
except ImportError:
import sys
import sys
# 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__:
print("SKIP")

View File

@ -1,12 +1,8 @@
# test sys.tracebacklimit
try:
try:
import usys as sys
import uio as io
except ImportError:
import sys
import io
import sys
import io
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,35 +1,35 @@
Traceback (most recent call last):
File , line 62, in ftop
File , line 57, in f3
File , line 53, in f2
File , line 49, in f1
File , line 45, in f0
File , line 58, in ftop
File , line 53, in f3
File , line 49, in f2
File , line 45, in f1
File , line 41, in f0
ValueError: value
limit 4
Traceback (most recent call last):
File , line 62, in ftop
File , line 57, in f3
File , line 53, in f2
File , line 49, in f1
File , line 58, in ftop
File , line 53, in f3
File , line 49, in f2
File , line 45, in f1
ValueError: value
limit 3
Traceback (most recent call last):
File , line 62, in ftop
File , line 57, in f3
File , line 53, in f2
File , line 58, in ftop
File , line 53, in f3
File , line 49, in f2
ValueError: value
limit 2
Traceback (most recent call last):
File , line 62, in ftop
File , line 57, in f3
File , line 58, in ftop
File , line 53, in f3
ValueError: value
limit 1
Traceback (most recent call last):
File , line 62, in ftop
File , line 58, in ftop
ValueError: value
limit 0

View File

@ -1,3 +1,3 @@
import uos
import os
uos.putenv('MICROPYINSPECT', '1')
os.putenv('MICROPYINSPECT', '1')

View File

@ -1,6 +1,6 @@
# test changing ps1/ps2
import usys
usys.ps1 = "PS1"
usys.ps2 = "PS2"
import sys
sys.ps1 = "PS1"
sys.ps2 = "PS2"
(1 +
2)

View File

@ -1,9 +1,9 @@
MicroPython \.\+ version
Use \.\+
>>> # test changing ps1/ps2
>>> import usys
>>> usys.ps1 = "PS1"
PS1usys.ps2 = "PS2"
>>> import sys
>>> sys.ps1 = "PS1"
PS1sys.ps2 = "PS2"
PS1(1 +
PS22)
3

View File

@ -22,10 +22,10 @@ def log(*args):
# replace boot.py with the test code that will run on each reboot
import uos
import os
try:
uos.rename("boot.py", "boot-orig.py")
os.rename("boot.py", "boot-orig.py")
except:
pass
with open("boot.py", "w") as f:
@ -74,10 +74,10 @@ elif STEP == 3:
elif STEP == 4:
log("Confirming boot ok and DONE!")
Partition.mark_app_valid_cancel_rollback()
import uos
uos.remove("step.py")
uos.remove("boot.py")
uos.rename("boot-orig.py", "boot.py")
import os
os.remove("step.py")
os.remove("boot.py")
os.rename("boot-orig.py", "boot.py")
print("\\nSUCCESS!\\n\\x04\\x04")
"""

View File

@ -5,10 +5,7 @@ if sys.implementation.name == "micropython" and sys.platform != "esp32":
print("SKIP")
raise SystemExit
try:
import usocket as socket, sys
except:
import socket, sys
import socket, sys
def test_bind_resolves_0_0_0_0():

View File

@ -1,8 +1,5 @@
try:
try:
import ubinascii as binascii
except ImportError:
import binascii
import binascii
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,8 +1,5 @@
try:
try:
import ubinascii as binascii
except ImportError:
import binascii
import binascii
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,8 +1,5 @@
try:
try:
import ubinascii as binascii
except ImportError:
import binascii
import binascii
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,8 +1,5 @@
try:
try:
import ubinascii as binascii
except ImportError:
import binascii
import binascii
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,8 +1,5 @@
try:
try:
import ubinascii as binascii
except ImportError:
import binascii
import binascii
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,13 +1,13 @@
try:
import btree
import uio
import uerrno
import io
import errno
except ImportError:
print("SKIP")
raise SystemExit
# f = open("_test.db", "w+b")
f = uio.BytesIO()
f = io.BytesIO()
db = btree.open(f, pagesize=512)
mv = memoryview(b"bar1foo1")
@ -68,7 +68,7 @@ print(db.seq(1, b"qux"))
try:
db.seq(b"foo1")
except OSError as e:
print(e.errno == uerrno.EINVAL)
print(e.errno == errno.EINVAL)
print(list(db.keys()))
print(list(db.values()))

View File

@ -1,15 +1,15 @@
# Test that errno's propagate correctly through btree module.
try:
import btree, uio, uerrno
import btree, io, errno
uio.IOBase
io.IOBase
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
class Device(uio.IOBase):
class Device(io.IOBase):
def __init__(self, read_ret=0, ioctl_ret=0):
self.read_ret = read_ret
self.ioctl_ret = ioctl_ret
@ -25,18 +25,24 @@ class Device(uio.IOBase):
# Invalid pagesize; errno comes from btree library
try:
import btree, io, errno
db = btree.open(Device(), pagesize=511)
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
try:
import btree, io, errno
db = btree.open(Device(-1000), pagesize=512)
except OSError as er:
print(repr(er))
# Valid pagesize, device returns error on seek; errno comes from Device.ioctl
try:
import btree, io, errno
db = btree.open(Device(0, -1001), pagesize=512)
except OSError as er:
print(repr(er))

View File

@ -1,7 +1,7 @@
# Test btree interaction with the garbage collector.
try:
import btree, uio, gc
import btree, io, gc
except ImportError:
print("SKIP")
raise SystemExit
@ -9,7 +9,7 @@ except ImportError:
N = 80
# 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.
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

View File

@ -4,7 +4,7 @@ try:
aes = AES.new
except ImportError:
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,5 +1,5 @@
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -4,7 +4,7 @@ try:
aes = AES.new
except ImportError:
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -7,7 +7,7 @@ try:
aes = AES.new
except ImportError:
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,6 +1,6 @@
# Inplace operations (input and output buffer is the same)
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,6 +1,6 @@
# Operations with pre-allocated output buffer
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -4,7 +4,7 @@ try:
aes = AES.new
except ImportError:
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -4,7 +4,7 @@ try:
aes = AES.new
except ImportError:
try:
from ucryptolib import aes
from cryptolib import aes
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,11 +1,11 @@
try:
import framebuf, usys
import framebuf, sys
except ImportError:
print("SKIP")
raise SystemExit
# This test and its .exp file is based on a little-endian architecture.
if usys.byteorder != "little":
if sys.byteorder != "little":
print("SKIP")
raise SystemExit

View File

@ -1,6 +1,6 @@
# Test blit between different color spaces
try:
import framebuf, usys
import framebuf, sys
except ImportError:
print("SKIP")
raise SystemExit

View File

@ -1,13 +1,13 @@
# test subclassing framebuf.FrameBuffer
try:
import framebuf, usys
import framebuf, sys
except ImportError:
print("SKIP")
raise SystemExit
# This test and its .exp file is based on a little-endian architecture.
if usys.byteorder != "little":
if sys.byteorder != "little":
print("SKIP")
raise SystemExit

View File

@ -1,12 +1,12 @@
try:
import uhashlib
import hashlib
except ImportError:
print("SKIP")
raise SystemExit
for algo_name in ("md5", "sha1", "sha256"):
algo = getattr(uhashlib, algo_name, None)
algo = getattr(hashlib, algo_name, None)
if not algo:
continue

View 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())

View 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())

View File

@ -1,13 +1,10 @@
try:
import uhashlib as hashlib
import hashlib
except ImportError:
try:
import hashlib
except ImportError:
# This is neither uPy, nor cPy, so must be uPy with
# uhashlib module disabled.
print("SKIP")
raise SystemExit
# This is neither uPy, nor cPy, so must be uPy with
# hashlib module disabled.
print("SKIP")
raise SystemExit
h = hashlib.sha256()

Some files were not shown because too many files have changed in this diff Show More