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");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test array + array
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test construction of array.array from different objects
|
||||
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test construction of array.array from different objects
|
||||
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test array types QqLl that require big-ints
|
||||
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test MicroPython-specific features of array.array
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test construction of bytearray from different objects
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test construction of bytearray from different objects
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test bytes + other
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test bytes + other
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
# test construction of bytes from different objects
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test construction of bytes from different objects
|
||||
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test using an OrderedDict as the locals to construct a class
|
||||
|
||||
try:
|
||||
from ucollections import OrderedDict
|
||||
except ImportError:
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -5,9 +5,6 @@
|
||||
try:
|
||||
from collections import namedtuple
|
||||
except ImportError:
|
||||
try:
|
||||
from ucollections import namedtuple
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
from ucollections import deque
|
||||
except ImportError:
|
||||
from collections import deque
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
|
@ -1,9 +1,6 @@
|
||||
# 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
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
|
@ -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
|
||||
|
@ -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__)
|
||||
|
@ -3,4 +3,4 @@
|
||||
[Errno ] EIO: details
|
||||
( , 'details', 'more details')
|
||||
9999
|
||||
uerrno
|
||||
errno
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
import uio as io
|
||||
import io
|
||||
|
||||
try:
|
||||
io.BytesIO
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -1,8 +1,4 @@
|
||||
try:
|
||||
import uio as io
|
||||
except ImportError:
|
||||
import io
|
||||
|
||||
import io
|
||||
a = io.BytesIO(b"foobar")
|
||||
try:
|
||||
a.seek(-10)
|
||||
|
@ -1,8 +1,4 @@
|
||||
try:
|
||||
import uio as io
|
||||
except:
|
||||
import io
|
||||
|
||||
import io
|
||||
try:
|
||||
io.IOBase
|
||||
except AttributeError:
|
||||
|
@ -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())
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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())
|
||||
|
@ -5,11 +5,8 @@ except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -5,11 +5,8 @@ except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -5,11 +5,8 @@ except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -4,11 +4,8 @@ except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
try:
|
||||
from uarray import array
|
||||
except ImportError:
|
||||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -7,11 +7,8 @@ except (NameError, TypeError):
|
||||
raise SystemExit
|
||||
|
||||
try:
|
||||
import uarray as array
|
||||
except ImportError:
|
||||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -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")
|
||||
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
from ucollections import namedtuple
|
||||
except ImportError:
|
||||
from collections import namedtuple
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
from ucollections import namedtuple
|
||||
except ImportError:
|
||||
from collections import namedtuple
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
try:
|
||||
from ucollections import OrderedDict
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
try:
|
||||
from ucollections import OrderedDict
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
import ustruct as struct
|
||||
except:
|
||||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
try:
|
||||
import ustruct as struct
|
||||
except:
|
||||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# 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:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test ustruct and endian specific things
|
||||
# test struct and endian specific things
|
||||
|
||||
try:
|
||||
import ustruct as struct
|
||||
except:
|
||||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
# test MicroPython-specific features of struct
|
||||
|
||||
try:
|
||||
import ustruct as struct
|
||||
except:
|
||||
try:
|
||||
import struct
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
@ -4,9 +4,6 @@
|
||||
# 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
|
||||
machine.PinBase
|
||||
machine.Signal
|
||||
|
@ -29,7 +29,6 @@ except Exception as bad:
|
||||
print(type(bad), bad.args[0])
|
||||
|
||||
try:
|
||||
|
||||
def gen():
|
||||
yield
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -1,10 +1,6 @@
|
||||
# test sys.tracebacklimit
|
||||
|
||||
try:
|
||||
try:
|
||||
import usys as sys
|
||||
import uio as io
|
||||
except ImportError:
|
||||
import sys
|
||||
import io
|
||||
except ImportError:
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,3 @@
|
||||
import uos
|
||||
import os
|
||||
|
||||
uos.putenv('MICROPYINSPECT', '1')
|
||||
os.putenv('MICROPYINSPECT', '1')
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
||||
"""
|
||||
|
@ -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():
|
||||
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
except ImportError:
|
||||
print("SKIP")
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
except ImportError:
|
||||
print("SKIP")
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
except ImportError:
|
||||
print("SKIP")
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
except ImportError:
|
||||
print("SKIP")
|
@ -1,7 +1,4 @@
|
||||
try:
|
||||
try:
|
||||
import ubinascii as binascii
|
||||
except ImportError:
|
||||
import binascii
|
||||
except ImportError:
|
||||
print("SKIP")
|
@ -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()))
|
||||
|
@ -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))
|
||||
|
@ -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]
|
||||
|
@ -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
|
@ -1,5 +1,5 @@
|
||||
try:
|
||||
from ucryptolib import aes
|
||||
from cryptolib import aes
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Test blit between different color spaces
|
||||
try:
|
||||
import framebuf, usys
|
||||
import framebuf, sys
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
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,11 +1,8 @@
|
||||
try:
|
||||
import uhashlib as hashlib
|
||||
except ImportError:
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
except ImportError:
|
||||
# This is neither uPy, nor cPy, so must be uPy with
|
||||
# uhashlib module disabled.
|
||||
# hashlib module disabled.
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user