diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 2ba8efb1fe..4bd612d37b 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -357,6 +357,6 @@ const mp_obj_module_t mp_module_uasyncio = { .globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals, }; -MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio); +MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_uasyncio); #endif // MICROPY_PY_UASYNCIO diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index d95f6f5554..6346b23e62 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -330,6 +330,6 @@ const mp_obj_module_t mp_module_ubinascii = { .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii); +MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii); #endif // MICROPY_PY_UBINASCII diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 11f8d1e03d..64100bb499 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -382,6 +382,6 @@ const mp_obj_module_t mp_module_uhashlib = { .globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib); +MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_uhashlib); #endif // MICROPY_PY_UHASHLIB diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index f48d9bceb1..c102e830ff 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -120,7 +120,7 @@ const mp_obj_module_t mp_module_uheapq = { .globals = (mp_obj_dict_t *)&mp_module_uheapq_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq); +MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_uheapq); #endif #endif // MICROPY_PY_UHEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index 14e45e2cc1..26241fa230 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -458,6 +458,6 @@ const mp_obj_module_t mp_module_ujson = { .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson); +MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson); #endif // MICROPY_PY_UJSON diff --git a/extmod/moduos.c b/extmod/moduos.c index a1752deb4a..4cbdf72627 100644 --- a/extmod/moduos.c +++ b/extmod/moduos.c @@ -181,6 +181,6 @@ const mp_obj_module_t mp_module_uos = { .globals = (mp_obj_dict_t *)&os_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos); +MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos); #endif // MICROPY_PY_UOS diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c index 1b35b08aa7..3590943bb1 100644 --- a/extmod/moduplatform.c +++ b/extmod/moduplatform.c @@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_uplatform = { .globals = (mp_obj_dict_t *)&modplatform_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform); +MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_uplatform); #endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modurandom.c b/extmod/modurandom.c index b661627190..68ebed32d3 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_urandom = { .globals = (mp_obj_dict_t *)&mp_module_urandom_globals, }; -MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom); +MP_REGISTER_MODULE(MP_QSTR_random, mp_module_urandom); #endif #endif // MICROPY_PY_URANDOM diff --git a/extmod/modure.c b/extmod/modure.c index 805c23d4ad..7ad6ccabce 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -491,7 +491,7 @@ const mp_obj_module_t mp_module_ure = { .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; -MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure); +MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure); #endif // Source files #include'd here to make sure they're compiled in diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c deleted file mode 100644 index 7cabfee4be..0000000000 --- a/extmod/modutimeq.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Damien P. George - * Copyright (c) 2016-2017 Paul Sokolovsky - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include "py/objlist.h" -#include "py/runtime.h" -#include "py/smallint.h" - -#include "supervisor/shared/translate/translate.h" - -#if MICROPY_PY_UTIMEQ - -#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD - -#define DEBUG 0 - -// the algorithm here is modelled on CPython's heapq.py - -struct qentry { - mp_uint_t time; - mp_uint_t id; - mp_obj_t callback; - mp_obj_t args; -}; - -typedef struct _mp_obj_utimeq_t { - mp_obj_base_t base; - mp_uint_t alloc; - mp_uint_t len; - struct qentry items[]; -} mp_obj_utimeq_t; - -STATIC mp_uint_t utimeq_id; - -STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) { - return MP_OBJ_TO_PTR(heap_in); -} - -STATIC bool time_less_than(struct qentry *item, struct qentry *parent) { - mp_uint_t item_tm = item->time; - mp_uint_t parent_tm = parent->time; - mp_uint_t res = parent_tm - item_tm; - if (res == 0) { - // TODO: This actually should use the same "ring" logic - // as for time, to avoid artifacts when id's overflow. - return item->id < parent->id; - } - if ((mp_int_t)res < 0) { - res += MODULO; - } - return res && res < (MODULO / 2); -} - -STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 1, 1, false); - mp_uint_t alloc = mp_obj_get_int(args[0]); - mp_obj_utimeq_t *o = mp_obj_malloc_var(mp_obj_utimeq_t, struct qentry, alloc, type); - memset(o->items, 0, sizeof(*o->items) * alloc); - o->alloc = alloc; - o->len = 0; - return MP_OBJ_FROM_PTR(o); -} - -STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) { - struct qentry item = heap->items[pos]; - while (pos > start_pos) { - mp_uint_t parent_pos = (pos - 1) >> 1; - struct qentry *parent = &heap->items[parent_pos]; - bool lessthan = time_less_than(&item, parent); - if (lessthan) { - heap->items[pos] = *parent; - pos = parent_pos; - } else { - break; - } - } - heap->items[pos] = item; -} - -STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) { - mp_uint_t start_pos = pos; - mp_uint_t end_pos = heap->len; - struct qentry item = heap->items[pos]; - for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) { - // choose right child if it's <= left child - if (child_pos + 1 < end_pos) { - bool lessthan = time_less_than(&heap->items[child_pos], &heap->items[child_pos + 1]); - if (!lessthan) { - child_pos += 1; - } - } - // bubble up the smaller child - heap->items[pos] = heap->items[child_pos]; - pos = child_pos; - } - heap->items[pos] = item; - utimeq_heap_siftdown(heap, start_pos, pos); -} - -STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) { - (void)n_args; - mp_obj_t heap_in = args[0]; - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); - if (heap->len == heap->alloc) { - mp_raise_IndexError(MP_ERROR_TEXT("queue overflow")); - } - mp_uint_t l = heap->len; - heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]); - heap->items[l].id = utimeq_id++; - heap->items[l].callback = args[2]; - heap->items[l].args = args[3]; - utimeq_heap_siftdown(heap, 0, heap->len); - heap->len++; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush); - -STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); - if (heap->len == 0) { - mp_raise_IndexError(MP_ERROR_TEXT("empty heap")); - } - mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref); - if (!mp_obj_is_type(list_ref, &mp_type_list) || ret->len < 3) { - mp_raise_TypeError(NULL); - } - - struct qentry *item = &heap->items[0]; - ret->items[0] = MP_OBJ_NEW_SMALL_INT(item->time); - ret->items[1] = item->callback; - ret->items[2] = item->args; - heap->len -= 1; - heap->items[0] = heap->items[heap->len]; - heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer - heap->items[heap->len].args = MP_OBJ_NULL; - if (heap->len) { - utimeq_heap_siftup(heap, 0); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop); - -STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); - if (heap->len == 0) { - mp_raise_IndexError(MP_ERROR_TEXT("empty heap")); - } - - struct qentry *item = &heap->items[0]; - return MP_OBJ_NEW_SMALL_INT(item->time); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime); - -#if DEBUG -STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) { - mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in); - for (int i = 0; i < heap->len; i++) { - printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time, - MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args)); - } - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump); -#endif - -STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_BOOL: - return mp_obj_new_bool(self->len != 0); - case MP_UNARY_OP_LEN: - return MP_OBJ_NEW_SMALL_INT(self->len); - default: - return MP_OBJ_NULL; // op not supported - } -} - -STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_utimeq_heappush_obj) }, - { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_utimeq_heappop_obj) }, - { MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_utimeq_peektime_obj) }, - #if DEBUG - { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_utimeq_dump_obj) }, - #endif -}; - -STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table); - -STATIC const mp_obj_type_t utimeq_type = { - { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, - .name = MP_QSTR_utimeq, - .make_new = utimeq_make_new, - .locals_dict = (void *)&utimeq_locals_dict, - MP_TYPE_EXTENDED_FIELDS( - .unary_op = utimeq_unary_op, - ), -}; - -STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) }, - { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&utimeq_type) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table); - -const mp_obj_module_t mp_module_utimeq = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&mp_module_utimeq_globals, -}; - -MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq); - -#endif // MICROPY_PY_UTIMEQ diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 5c16ea732c..b2f5b5af33 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -230,7 +230,7 @@ const mp_obj_module_t mp_module_uzlib = { }; -MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib); +MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_uzlib); #endif // Source files #include'd here to make sure they're compiled in diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index d2f730a602..058abab5ce 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -326,12 +326,12 @@ STATIC mp_obj_t extra_coverage(void) { size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &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); 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); + len = mp_repl_autocomplete("import ti", 9, &mp_plat_print, &str); mp_printf(&mp_plat_print, "%.*s\n", (int)len, str); - mp_repl_autocomplete("import utime", 12, &mp_plat_print, &str); + mp_repl_autocomplete("import ra", 9, &mp_plat_print, &str); 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); diff --git a/ports/unix/modtime.c b/ports/unix/modtime.c index c9eb09c15b..cec8baa8cd 100644 --- a/ports/unix/modtime.c +++ b/ports/unix/modtime.c @@ -232,6 +232,6 @@ const mp_obj_module_t mp_module_time = { .globals = (mp_obj_dict_t *)&mp_module_time_globals, }; -MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time); +MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time); #endif // MICROPY_PY_UTIME diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index 7bfcf8fc56..8295f3d8b5 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -354,6 +354,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect); +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect); #endif // MICROPY_PY_USELECT_POSIX diff --git a/py/modio.c b/py/modio.c index 836d04fb11..985903ffe7 100644 --- a/py/modio.c +++ b/py/modio.c @@ -245,6 +245,6 @@ const mp_obj_module_t mp_module_io = { .globals = (mp_obj_dict_t *)&mp_module_io_globals, }; -MP_REGISTER_MODULE(MP_QSTR_uio, mp_module_io); +MP_REGISTER_MODULE(MP_QSTR_io, mp_module_io); #endif diff --git a/py/modsys.c b/py/modsys.c index 63fb654f05..68d254641a 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -282,6 +282,6 @@ const mp_obj_module_t mp_module_sys = { .globals = (mp_obj_dict_t *)&mp_module_sys_globals, }; -MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys); +MP_REGISTER_MODULE(MP_QSTR_sys, mp_module_sys); #endif diff --git a/py/moduerrno.c b/py/moduerrno.c index cf3cbe064f..a132474e4c 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -105,11 +105,7 @@ const mp_obj_module_t mp_module_uerrno = { .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, }; -#if defined(MICROPY_UNIX_COVERAGE) -MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno); -#else MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno); -#endif qstr mp_errno_to_str(mp_obj_t errno_val) { // Otherwise, return the Exxxx string for that error code diff --git a/py/py.mk b/py/py.mk index 81da81ba0f..d26b8752a4 100644 --- a/py/py.mk +++ b/py/py.mk @@ -195,7 +195,6 @@ PY_EXTMOD_O_BASENAME = \ extmod/modure.o \ extmod/moduzlib.o \ extmod/moduheapq.o \ - extmod/modutimeq.o \ extmod/moduhashlib.o \ extmod/modubinascii.o \ extmod/modurandom.o \ diff --git a/tests/basics/array1.py b/tests/basics/array1.py index f21ad4bd75..5c5d13a581 100644 --- a/tests/basics/array1.py +++ b/tests/basics/array1.py @@ -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)) diff --git a/tests/basics/array_add.py b/tests/basics/array_add.py index 8335eb6b82..76ce59f761 100644 --- a/tests/basics/array_add.py +++ b/tests/basics/array_add.py @@ -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]) diff --git a/tests/basics/array_micropython.py b/tests/basics/array_micropython.py index 44dc1d83d8..771a7d709c 100644 --- a/tests/basics/array_micropython.py +++ b/tests/basics/array_micropython.py @@ -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') diff --git a/tests/basics/bytes_add_array.py b/tests/basics/bytes_add_array.py index c6382bed74..b17556d83c 100644 --- a/tests/basics/bytes_add_array.py +++ b/tests/basics/bytes_add_array.py @@ -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])) diff --git a/tests/basics/bytes_add_endian.py b/tests/basics/bytes_add_endian.py index 40b3de7d61..8cfffa7b6a 100644 --- a/tests/basics/bytes_add_endian.py +++ b/tests/basics/bytes_add_endian.py @@ -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])) diff --git a/tests/basics/bytes_compare_array.py b/tests/basics/bytes_compare_array.py index 6bad50b55a..ad378de70c 100644 --- a/tests/basics/bytes_compare_array.py +++ b/tests/basics/bytes_compare_array.py @@ -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 diff --git a/tests/basics/dict_fixed.py b/tests/basics/dict_fixed.py index 4261a06557..cfd3b71f57 100644 --- a/tests/basics/dict_fixed.py +++ b/tests/basics/dict_fixed.py @@ -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 diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py index d9a895a972..0773c926fd 100644 --- a/tests/basics/errno1.py +++ b/tests/basics/errno1.py @@ -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__) diff --git a/tests/basics/io_buffered_writer.py b/tests/basics/io_buffered_writer.py index 64e5fa1ee7..b3bab54900 100644 --- a/tests/basics/io_buffered_writer.py +++ b/tests/basics/io_buffered_writer.py @@ -1,4 +1,4 @@ -import uio as io +import io try: io.BytesIO diff --git a/tests/basics/io_bytesio_cow.py b/tests/basics/io_bytesio_cow.py index 92654a0003..543dd484ab 100644 --- a/tests/basics/io_bytesio_cow.py +++ b/tests/basics/io_bytesio_cow.py @@ -1,9 +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" diff --git a/tests/basics/io_bytesio_ext.py b/tests/basics/io_bytesio_ext.py index e454b2fd9f..eee20baf3b 100644 --- a/tests/basics/io_bytesio_ext.py +++ b/tests/basics/io_bytesio_ext.py @@ -1,8 +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) diff --git a/tests/basics/io_bytesio_ext2.py b/tests/basics/io_bytesio_ext2.py index 8f624fd58c..5bede33f58 100644 --- a/tests/basics/io_bytesio_ext2.py +++ b/tests/basics/io_bytesio_ext2.py @@ -1,7 +1,4 @@ -try: - import uio as io -except ImportError: - import io +import io a = io.BytesIO(b"foobar") try: diff --git a/tests/basics/io_iobase.py b/tests/basics/io_iobase.py index 667e629858..6d27fe1e74 100644 --- a/tests/basics/io_iobase.py +++ b/tests/basics/io_iobase.py @@ -1,7 +1,4 @@ -try: - import uio as io -except: - import io +import io try: io.IOBase diff --git a/tests/basics/io_stringio1.py b/tests/basics/io_stringio1.py index c4ac9ec076..2174db00cd 100644 --- a/tests/basics/io_stringio1.py +++ b/tests/basics/io_stringio1.py @@ -1,7 +1,4 @@ -try: - import uio as io -except ImportError: - import io +import io a = io.StringIO() print("io.StringIO" in repr(a)) diff --git a/tests/basics/io_stringio_with.py b/tests/basics/io_stringio_with.py index c35975445d..b30395672c 100644 --- a/tests/basics/io_stringio_with.py +++ b/tests/basics/io_stringio_with.py @@ -1,7 +1,4 @@ -try: - import uio as io -except ImportError: - import io +import io # test __enter__/__exit__ with io.StringIO() as b: diff --git a/tests/basics/io_write_ext.py b/tests/basics/io_write_ext.py index 18cd75ddb6..79f7450954 100644 --- a/tests/basics/io_write_ext.py +++ b/tests/basics/io_write_ext.py @@ -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()) diff --git a/tests/basics/memoryview1.py b/tests/basics/memoryview1.py index 4c20c91f49..1ebfbc53b9 100644 --- a/tests/basics/memoryview1.py +++ b/tests/basics/memoryview1.py @@ -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' diff --git a/tests/basics/memoryview_slice_assign.py b/tests/basics/memoryview_slice_assign.py index 74f6fae6f7..94f8073f0a 100644 --- a/tests/basics/memoryview_slice_assign.py +++ b/tests/basics/memoryview_slice_assign.py @@ -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') diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index 2ac900bbc7..f6c521d6ce 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -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(">> # test changing ps1/ps2 ->>> import usys ->>> usys.ps1 = "PS1" -PS1usys.ps2 = "PS2" +>>> import sys +>>> sys.ps1 = "PS1" +PS1sys.ps2 = "PS2" PS1(1 + PS22) 3 diff --git a/tests/extmod/btree1.py b/tests/extmod/btree1.py deleted file mode 100644 index 1f4853eaa3..0000000000 --- a/tests/extmod/btree1.py +++ /dev/null @@ -1,89 +0,0 @@ -try: - import btree - import uio - import uerrno -except ImportError: - print("SKIP") - raise SystemExit - -# f = open("_test.db", "w+b") -f = uio.BytesIO() -db = btree.open(f, pagesize=512) - -db[b"foo3"] = b"bar3" -db[b"foo1"] = b"bar1" -db[b"foo2"] = b"bar2" -db[b"bar1"] = b"foo1" - -dbstr = str(db) -print(dbstr[:7], dbstr[-1:]) - -print(db[b"foo2"]) -try: - print(db[b"foo"]) -except KeyError: - print("KeyError") -print(db.get(b"foo")) -print(db.get(b"foo", b"dflt")) - -del db[b"foo2"] -try: - del db[b"foo"] -except KeyError: - print("KeyError") - -for k, v in db.items(): - print((k, v)) - -print("---") -for k, v in db.items(None, None): - print((k, v)) - -print("---") -for k, v in db.items(b"f"): - print((k, v)) - -print("---") -for k, v in db.items(b"f", b"foo3"): - print((k, v)) - -print("---") -for k, v in db.items(None, b"foo3"): - print((k, v)) - -print("---") -for k, v in db.items(b"f", b"foo3", btree.INCL): - print((k, v)) - -print("---") -for k, v in db.items(None, None, btree.DESC): - print((k, v)) - -print(db.seq(1, b"foo1")) -print(db.seq(1, b"qux")) - -try: - db.seq(b"foo1") -except OSError as e: - print(e.errno == uerrno.EINVAL) - -print(list(db.keys())) -print(list(db.values())) - -for k in db: - print(k) - -db.put(b"baz1", b"qux1") - -print("foo1", "foo1" in db) -print("foo2", "foo2" in db) -print("baz1", "baz1" in db) - -try: - print(db + db[b"foo1"]) -except TypeError: - print("TypeError") - -db.flush() -db.close() -f.close() diff --git a/tests/extmod/btree1.py.exp b/tests/extmod/btree1.py.exp deleted file mode 100644 index a467252300..0000000000 --- a/tests/extmod/btree1.py.exp +++ /dev/null @@ -1,40 +0,0 @@ - -b'bar2' -KeyError -None -b'dflt' -KeyError -(b'bar1', b'foo1') -(b'foo1', b'bar1') -(b'foo3', b'bar3') ---- -(b'bar1', b'foo1') -(b'foo1', b'bar1') -(b'foo3', b'bar3') ---- -(b'foo1', b'bar1') -(b'foo3', b'bar3') ---- -(b'foo1', b'bar1') ---- -(b'bar1', b'foo1') -(b'foo1', b'bar1') ---- -(b'foo1', b'bar1') -(b'foo3', b'bar3') ---- -(b'foo3', b'bar3') -(b'foo1', b'bar1') -(b'bar1', b'foo1') -(b'foo1', b'bar1') -None -True -[b'bar1', b'foo1', b'foo3'] -[b'foo1', b'bar1', b'bar3'] -b'bar1' -b'foo1' -b'foo3' -foo1 True -foo2 False -baz1 True -TypeError diff --git a/tests/extmod/btree_error.py b/tests/extmod/btree_error.py deleted file mode 100644 index b64769e884..0000000000 --- a/tests/extmod/btree_error.py +++ /dev/null @@ -1,42 +0,0 @@ -# Test that errno's propagate correctly through btree module. - -try: - import btree, uio, uerrno - - uio.IOBase -except (ImportError, AttributeError): - print("SKIP") - raise SystemExit - - -class Device(uio.IOBase): - def __init__(self, read_ret=0, ioctl_ret=0): - self.read_ret = read_ret - self.ioctl_ret = ioctl_ret - - def readinto(self, buf): - print("read", len(buf)) - return self.read_ret - - def ioctl(self, cmd, arg): - print("ioctl", cmd) - return self.ioctl_ret - - -# Invalid pagesize; errno comes from btree library -try: - db = btree.open(Device(), pagesize=511) -except OSError as er: - print("OSError", er.errno == uerrno.EINVAL) - -# Valid pagesize, device returns error on read; errno comes from Device.readinto -try: - 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: - db = btree.open(Device(0, -1001), pagesize=512) -except OSError as er: - print(repr(er)) diff --git a/tests/extmod/btree_error.py.exp b/tests/extmod/btree_error.py.exp deleted file mode 100644 index 168adb80c5..0000000000 --- a/tests/extmod/btree_error.py.exp +++ /dev/null @@ -1,6 +0,0 @@ -OSError True -read 24 -OSError(1000,) -read 24 -ioctl 2 -OSError(1001,) diff --git a/tests/extmod/btree_gc.py b/tests/extmod/btree_gc.py deleted file mode 100644 index 1845aa0640..0000000000 --- a/tests/extmod/btree_gc.py +++ /dev/null @@ -1,26 +0,0 @@ -# Test btree interaction with the garbage collector. - -try: - import btree, uio, gc -except ImportError: - print("SKIP") - raise SystemExit - -N = 80 - -# Create a BytesIO but don't keep a reference to it. -db = btree.open(uio.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] - -# Write lots of key/value pairs, which fill up the DB and also allocate temporary heap -# memory due to the string addition, and do a GC collect to verify that the BytesIO -# is not collected. -for i in range(N): - db[b"thekey" + str(i)] = b"thelongvalue" + str(i) - print(db[b"thekey" + str(i)]) - gc.collect() - -# Reclaim memory allocated by the db object. -db.close() diff --git a/tests/extmod/btree_gc.py.exp b/tests/extmod/btree_gc.py.exp deleted file mode 100644 index e7b8d56729..0000000000 --- a/tests/extmod/btree_gc.py.exp +++ /dev/null @@ -1,80 +0,0 @@ -b'thelongvalue0' -b'thelongvalue1' -b'thelongvalue2' -b'thelongvalue3' -b'thelongvalue4' -b'thelongvalue5' -b'thelongvalue6' -b'thelongvalue7' -b'thelongvalue8' -b'thelongvalue9' -b'thelongvalue10' -b'thelongvalue11' -b'thelongvalue12' -b'thelongvalue13' -b'thelongvalue14' -b'thelongvalue15' -b'thelongvalue16' -b'thelongvalue17' -b'thelongvalue18' -b'thelongvalue19' -b'thelongvalue20' -b'thelongvalue21' -b'thelongvalue22' -b'thelongvalue23' -b'thelongvalue24' -b'thelongvalue25' -b'thelongvalue26' -b'thelongvalue27' -b'thelongvalue28' -b'thelongvalue29' -b'thelongvalue30' -b'thelongvalue31' -b'thelongvalue32' -b'thelongvalue33' -b'thelongvalue34' -b'thelongvalue35' -b'thelongvalue36' -b'thelongvalue37' -b'thelongvalue38' -b'thelongvalue39' -b'thelongvalue40' -b'thelongvalue41' -b'thelongvalue42' -b'thelongvalue43' -b'thelongvalue44' -b'thelongvalue45' -b'thelongvalue46' -b'thelongvalue47' -b'thelongvalue48' -b'thelongvalue49' -b'thelongvalue50' -b'thelongvalue51' -b'thelongvalue52' -b'thelongvalue53' -b'thelongvalue54' -b'thelongvalue55' -b'thelongvalue56' -b'thelongvalue57' -b'thelongvalue58' -b'thelongvalue59' -b'thelongvalue60' -b'thelongvalue61' -b'thelongvalue62' -b'thelongvalue63' -b'thelongvalue64' -b'thelongvalue65' -b'thelongvalue66' -b'thelongvalue67' -b'thelongvalue68' -b'thelongvalue69' -b'thelongvalue70' -b'thelongvalue71' -b'thelongvalue72' -b'thelongvalue73' -b'thelongvalue74' -b'thelongvalue75' -b'thelongvalue76' -b'thelongvalue77' -b'thelongvalue78' -b'thelongvalue79' diff --git a/tests/extmod/framebuf1.py b/tests/extmod/framebuf1.py deleted file mode 100644 index c8e0132265..0000000000 --- a/tests/extmod/framebuf1.py +++ /dev/null @@ -1,111 +0,0 @@ -try: - import framebuf -except ImportError: - print("SKIP") - raise SystemExit - -w = 5 -h = 16 -size = w * h // 8 -buf = bytearray(size) -maps = { - framebuf.MONO_VLSB: "MONO_VLSB", - framebuf.MONO_HLSB: "MONO_HLSB", - framebuf.MONO_HMSB: "MONO_HMSB", -} - -for mapping in maps.keys(): - for x in range(size): - buf[x] = 0 - fbuf = framebuf.FrameBuffer(buf, w, h, mapping) - print(maps[mapping]) - # access as buffer - print(memoryview(fbuf)[0]) - - # fill - fbuf.fill(1) - print(buf) - fbuf.fill(0) - print(buf) - - # put pixel - fbuf.pixel(0, 0, 1) - fbuf.pixel(4, 0, 1) - fbuf.pixel(0, 15, 1) - fbuf.pixel(4, 15, 1) - print(buf) - - # clear pixel - fbuf.pixel(4, 15, 0) - print(buf) - - # get pixel - print(fbuf.pixel(0, 0), fbuf.pixel(1, 1)) - - # hline - fbuf.fill(0) - fbuf.hline(0, 1, w, 1) - print("hline", buf) - - # vline - fbuf.fill(0) - fbuf.vline(1, 0, h, 1) - print("vline", buf) - - # rect - fbuf.fill(0) - fbuf.rect(1, 1, 3, 3, 1) - print("rect", buf) - - # fill rect - fbuf.fill(0) - fbuf.fill_rect(0, 0, 0, 3, 1) # zero width, no-operation - fbuf.fill_rect(1, 1, 3, 3, 1) - print("fill_rect", buf) - - # line - fbuf.fill(0) - fbuf.line(1, 1, 3, 3, 1) - print("line", buf) - - # line steep negative gradient - fbuf.fill(0) - fbuf.line(3, 3, 2, 1, 1) - print("line", buf) - - # scroll - fbuf.fill(0) - fbuf.pixel(2, 7, 1) - fbuf.scroll(0, 1) - print(buf) - fbuf.scroll(0, -2) - print(buf) - fbuf.scroll(1, 0) - print(buf) - fbuf.scroll(-1, 0) - print(buf) - fbuf.scroll(2, 2) - print(buf) - - # print text - fbuf.fill(0) - fbuf.text("hello", 0, 0, 1) - print(buf) - fbuf.text("hello", 0, 0, 0) # clear - print(buf) - - # char out of font range set to chr(127) - fbuf.text(str(chr(31)), 0, 0) - print(buf) - print() - -# test invalid constructor, and stride argument -try: - fbuf = framebuf.FrameBuffer(buf, w, h, -1, w) -except ValueError: - print("ValueError") - -# test legacy constructor -fbuf = framebuf.FrameBuffer1(buf, w, h) -fbuf = framebuf.FrameBuffer1(buf, w, h, w) -print(framebuf.MVLSB == framebuf.MONO_VLSB) diff --git a/tests/extmod/framebuf1.py.exp b/tests/extmod/framebuf1.py.exp deleted file mode 100644 index d954623dee..0000000000 --- a/tests/extmod/framebuf1.py.exp +++ /dev/null @@ -1,68 +0,0 @@ -MONO_VLSB -0 -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x80') -bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x00') -1 0 -hline bytearray(b'\x02\x02\x02\x02\x02\x00\x00\x00\x00\x00') -vline bytearray(b'\x00\xff\x00\x00\x00\x00\xff\x00\x00\x00') -rect bytearray(b'\x00\x0e\n\x0e\x00\x00\x00\x00\x00\x00') -fill_rect bytearray(b'\x00\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00\x02\x04\x08\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00\x00\x06\x08\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00') -bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00@\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') -bytearray(b'\x00\x7f\x7f\x04\x04\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\xaaU\xaaU\xaa\x00\x00\x00\x00\x00') - -MONO_HLSB -0 -bytearray(b'\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00') -1 0 -hline bytearray(b'\x00\xf8\x00\x00\x00\x00\x00\x00\x00\x00') -vline bytearray(b'@@@@@@@@@@') -rect bytearray(b'\x00pPp\x00\x00\x00\x00\x00\x00') -fill_rect bytearray(b'\x00ppp\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00@ \x10\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00 \x10\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00 \x00') -bytearray(b'\x00\x00\x00\x00\x00\x00 \x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00 \x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00') -bytearray(b'``x````\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'P\xa8P\xa8P\xa8P\xa8\x00\x00') - -MONO_HMSB -0 -bytearray(b'\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00') -1 0 -hline bytearray(b'\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00') -vline bytearray(b'\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02') -rect bytearray(b'\x00\x0e\n\x0e\x00\x00\x00\x00\x00\x00') -fill_rect bytearray(b'\x00\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00\x02\x04\x08\x00\x00\x00\x00\x00\x00') -line bytearray(b'\x00\x04\x04\x08\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00') -bytearray(b'\x06\x06\x1e\x06\x06\x06\x06\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\n\x15\n\x15\n\x15\n\x15\x00\x00') - -ValueError -True diff --git a/tests/extmod/framebuf16.py b/tests/extmod/framebuf16.py deleted file mode 100644 index cd7f5ec015..0000000000 --- a/tests/extmod/framebuf16.py +++ /dev/null @@ -1,66 +0,0 @@ -try: - import framebuf, usys -except ImportError: - print("SKIP") - raise SystemExit - -# This test and its .exp file is based on a little-endian architecture. -if usys.byteorder != "little": - print("SKIP") - raise SystemExit - - -def printbuf(): - print("--8<--") - for y in range(h): - print(buf[y * w * 2 : (y + 1) * w * 2]) - print("-->8--") - - -w = 4 -h = 5 -buf = bytearray(w * h * 2) -fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.RGB565) - -# fill -fbuf.fill(0xFFFF) -printbuf() -fbuf.fill(0x0000) -printbuf() - -# put pixel -fbuf.pixel(0, 0, 0xEEEE) -fbuf.pixel(3, 0, 0xEE00) -fbuf.pixel(0, 4, 0x00EE) -fbuf.pixel(3, 4, 0x0EE0) -printbuf() - -# get pixel -print(fbuf.pixel(0, 4), fbuf.pixel(1, 1)) - -# scroll -fbuf.fill(0x0000) -fbuf.pixel(2, 2, 0xFFFF) -printbuf() -fbuf.scroll(0, 1) -printbuf() -fbuf.scroll(1, 0) -printbuf() -fbuf.scroll(-1, -2) -printbuf() - -w2 = 2 -h2 = 3 -buf2 = bytearray(w2 * h2 * 2) -fbuf2 = framebuf.FrameBuffer(buf2, w2, h2, framebuf.RGB565) - -fbuf2.fill(0x0000) -fbuf2.pixel(0, 0, 0x0EE0) -fbuf2.pixel(0, 2, 0xEE00) -fbuf2.pixel(1, 0, 0x00EE) -fbuf2.pixel(1, 2, 0xE00E) -fbuf.fill(0xFFFF) -fbuf.blit(fbuf2, 3, 3, 0x0000) -fbuf.blit(fbuf2, -1, -1, 0x0000) -fbuf.blit(fbuf2, 16, 16, 0x0000) -printbuf() diff --git a/tests/extmod/framebuf16.py.exp b/tests/extmod/framebuf16.py.exp deleted file mode 100644 index c41dc19d07..0000000000 --- a/tests/extmod/framebuf16.py.exp +++ /dev/null @@ -1,57 +0,0 @@ ---8<-- -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\xee\xee\x00\x00\x00\x00\x00\xee') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\xee\x00\x00\x00\x00\x00\xe0\x0e') --->8-- -238 0 ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\xff\xff') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\xff\xff') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\x0e\xe0\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xe0\x0e') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') --->8-- diff --git a/tests/extmod/framebuf2.py b/tests/extmod/framebuf2.py deleted file mode 100644 index 097057fe96..0000000000 --- a/tests/extmod/framebuf2.py +++ /dev/null @@ -1,64 +0,0 @@ -try: - import framebuf -except ImportError: - print("SKIP") - raise SystemExit - - -def printbuf(): - print("--8<--") - for y in range(h): - for x in range(w): - print("%u" % ((buf[(x + y * w) // 4] >> ((x & 3) << 1)) & 3), end="") - print() - print("-->8--") - - -w = 8 -h = 5 -buf = bytearray(w * h // 4) -fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS2_HMSB) - -# fill -fbuf.fill(3) -printbuf() -fbuf.fill(0) -printbuf() - -# put pixel -fbuf.pixel(0, 0, 1) -fbuf.pixel(3, 0, 2) -fbuf.pixel(0, 4, 3) -fbuf.pixel(3, 4, 2) -printbuf() - -# get pixel -print(fbuf.pixel(0, 4), fbuf.pixel(1, 1)) - -# scroll -fbuf.fill(0) -fbuf.pixel(2, 2, 3) -printbuf() -fbuf.scroll(0, 1) -printbuf() -fbuf.scroll(1, 0) -printbuf() -fbuf.scroll(-1, -2) -printbuf() - -w2 = 2 -h2 = 3 -buf2 = bytearray(w2 * h2 // 4) -fbuf2 = framebuf.FrameBuffer(buf2, w2, h2, framebuf.GS2_HMSB) - -# blit -fbuf2.fill(0) -fbuf2.pixel(0, 0, 1) -fbuf2.pixel(0, 2, 2) -fbuf2.pixel(1, 0, 1) -fbuf2.pixel(1, 2, 2) -fbuf.fill(3) -fbuf.blit(fbuf2, 3, 3, 0) -fbuf.blit(fbuf2, -1, -1, 0) -fbuf.blit(fbuf2, 16, 16, 0) -printbuf() diff --git a/tests/extmod/framebuf2.py.exp b/tests/extmod/framebuf2.py.exp deleted file mode 100644 index c53e518a6e..0000000000 --- a/tests/extmod/framebuf2.py.exp +++ /dev/null @@ -1,57 +0,0 @@ ---8<-- -33333333 -33333333 -33333333 -33333333 -33333333 --->8-- ---8<-- -00000000 -00000000 -00000000 -00000000 -00000000 --->8-- ---8<-- -10020000 -00000000 -00000000 -00000000 -30020000 --->8-- -3 0 ---8<-- -00000000 -00000000 -00300000 -00000000 -00000000 --->8-- ---8<-- -00000000 -00000000 -00000000 -00300000 -00000000 --->8-- ---8<-- -00000000 -00000000 -00000000 -00030000 -00000000 --->8-- ---8<-- -00000000 -00300000 -00000000 -00030000 -00000000 --->8-- ---8<-- -33333333 -23333333 -33333333 -33311333 -33333333 --->8-- diff --git a/tests/extmod/framebuf4.py b/tests/extmod/framebuf4.py deleted file mode 100644 index 56593ee155..0000000000 --- a/tests/extmod/framebuf4.py +++ /dev/null @@ -1,55 +0,0 @@ -try: - import framebuf -except ImportError: - print("SKIP") - raise SystemExit - - -def printbuf(): - print("--8<--") - for y in range(h): - print(buf[y * w // 2 : (y + 1) * w // 2]) - print("-->8--") - - -w = 16 -h = 8 -buf = bytearray(w * h // 2) -fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS4_HMSB) - -# fill -fbuf.fill(0x0F) -printbuf() -fbuf.fill(0xA0) -printbuf() - -# put pixel -fbuf.pixel(0, 0, 0x01) -printbuf() -fbuf.pixel(w - 1, 0, 0x02) -printbuf() -fbuf.pixel(w - 1, h - 1, 0x03) -printbuf() -fbuf.pixel(0, h - 1, 0x04) -printbuf() - -# get pixel -print(fbuf.pixel(0, 0), fbuf.pixel(w - 1, 0), fbuf.pixel(w - 1, h - 1), fbuf.pixel(0, h - 1)) -print(fbuf.pixel(1, 0), fbuf.pixel(w - 2, 0), fbuf.pixel(w - 2, h - 1), fbuf.pixel(1, h - 1)) - -# fill rect -fbuf.fill_rect(0, 0, w, h, 0x0F) -printbuf() -fbuf.fill_rect(0, 0, w, h, 0xF0) -fbuf.fill_rect(1, 0, w // 2 + 1, 1, 0xF1) -printbuf() -fbuf.fill_rect(1, 0, w // 2 + 1, 1, 0x10) -fbuf.fill_rect(1, 0, w // 2, 1, 0xF1) -printbuf() -fbuf.fill_rect(1, 0, w // 2, 1, 0x10) -fbuf.fill_rect(0, h - 4, w // 2 + 1, 4, 0xAF) -printbuf() -fbuf.fill_rect(0, h - 4, w // 2 + 1, 4, 0xB0) -fbuf.fill_rect(0, h - 4, w // 2, 4, 0xAF) -printbuf() -fbuf.fill_rect(0, h - 4, w // 2, 4, 0xB0) diff --git a/tests/extmod/framebuf4.py.exp b/tests/extmod/framebuf4.py.exp deleted file mode 100644 index 0865470a07..0000000000 --- a/tests/extmod/framebuf4.py.exp +++ /dev/null @@ -1,112 +0,0 @@ ---8<-- -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x03') --->8-- ---8<-- -bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'@\x00\x00\x00\x00\x00\x00\x03') --->8-- -1 2 3 4 -0 0 0 0 ---8<-- -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') -bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff') --->8-- ---8<-- -bytearray(b'\x01\x11\x11\x11\x11\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x01\x11\x11\x11\x10\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00') --->8-- ---8<-- -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00') -bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00') --->8-- diff --git a/tests/extmod/framebuf8.py b/tests/extmod/framebuf8.py deleted file mode 100644 index a3ca6fcd4f..0000000000 --- a/tests/extmod/framebuf8.py +++ /dev/null @@ -1,34 +0,0 @@ -try: - import framebuf -except ImportError: - print("SKIP") - raise SystemExit - - -def printbuf(): - print("--8<--") - for y in range(h): - for x in range(w): - print("%02x" % buf[(x + y * w)], end="") - print() - print("-->8--") - - -w = 8 -h = 5 -buf = bytearray(w * h) -fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8) - -# fill -fbuf.fill(0x55) -printbuf() - -# put pixel -fbuf.pixel(0, 0, 0x11) -fbuf.pixel(w - 1, 0, 0x22) -fbuf.pixel(0, h - 1, 0x33) -fbuf.pixel(w - 1, h - 1, 0xFF) -printbuf() - -# get pixel -print(hex(fbuf.pixel(0, h - 1)), hex(fbuf.pixel(1, 1))) diff --git a/tests/extmod/framebuf8.py.exp b/tests/extmod/framebuf8.py.exp deleted file mode 100644 index 01d8976fec..0000000000 --- a/tests/extmod/framebuf8.py.exp +++ /dev/null @@ -1,15 +0,0 @@ ---8<-- -5555555555555555 -5555555555555555 -5555555555555555 -5555555555555555 -5555555555555555 --->8-- ---8<-- -1155555555555522 -5555555555555555 -5555555555555555 -5555555555555555 -33555555555555ff --->8-- -0x33 0x55 diff --git a/tests/extmod/framebuf_palette.py b/tests/extmod/framebuf_palette.py deleted file mode 100644 index f5b15fda73..0000000000 --- a/tests/extmod/framebuf_palette.py +++ /dev/null @@ -1,35 +0,0 @@ -# Test blit between different color spaces -try: - import framebuf, usys -except ImportError: - print("SKIP") - raise SystemExit - -# Monochrome glyph/icon -w = 8 -h = 8 -cbuf = bytearray(w * h // 8) -fbc = framebuf.FrameBuffer(cbuf, w, h, framebuf.MONO_HLSB) -fbc.line(0, 0, 7, 7, 1) - -# RGB565 destination -wd = 16 -hd = 16 -dest = bytearray(wd * hd * 2) -fbd = framebuf.FrameBuffer(dest, wd, hd, framebuf.RGB565) - -wp = 2 -bg = 0x1234 -fg = 0xF800 -pal = bytearray(wp * 2) -palette = framebuf.FrameBuffer(pal, wp, 1, framebuf.RGB565) -palette.pixel(0, 0, bg) -palette.pixel(1, 0, fg) - -fbd.blit(fbc, 0, 0, -1, palette) - -print(fbd.pixel(0, 0) == fg) -print(fbd.pixel(7, 7) == fg) -print(fbd.pixel(8, 8) == 0) # Outside blit -print(fbd.pixel(0, 1) == bg) -print(fbd.pixel(1, 0) == bg) diff --git a/tests/extmod/framebuf_palette.py.exp b/tests/extmod/framebuf_palette.py.exp deleted file mode 100644 index 2e883c51de..0000000000 --- a/tests/extmod/framebuf_palette.py.exp +++ /dev/null @@ -1,5 +0,0 @@ -True -True -True -True -True diff --git a/tests/extmod/framebuf_subclass.py b/tests/extmod/framebuf_subclass.py deleted file mode 100644 index 4cd9ea4eb5..0000000000 --- a/tests/extmod/framebuf_subclass.py +++ /dev/null @@ -1,51 +0,0 @@ -# test subclassing framebuf.FrameBuffer - -try: - import framebuf, usys -except ImportError: - print("SKIP") - raise SystemExit - -# This test and its .exp file is based on a little-endian architecture. -if usys.byteorder != "little": - print("SKIP") - raise SystemExit - - -class FB(framebuf.FrameBuffer): - def __init__(self, n): - self.n = n - super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565) - - def foo(self): - self.hline(0, 2, self.n, 0x0304) - - -fb = FB(n=3) -fb.pixel(0, 0, 0x0102) -fb.foo() -print(bytes(fb)) - -# Test that blitting a subclass works. -fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565) -fb.fill(0) -fb.pixel(0, 0, 0x0506) -fb.pixel(2, 2, 0x0708) -fb2.blit(fb, 0, 0) -print(bytes(fb2)) - - -# Test that blitting something that isn't a subclass fails with TypeError. -class NotAFrameBuf: - pass - - -try: - fb.blit(NotAFrameBuf(), 0, 0) -except TypeError: - print("TypeError") - -try: - fb.blit(None, 0, 0) -except TypeError: - print("TypeError") diff --git a/tests/extmod/framebuf_subclass.py.exp b/tests/extmod/framebuf_subclass.py.exp deleted file mode 100644 index 58e311fee5..0000000000 --- a/tests/extmod/framebuf_subclass.py.exp +++ /dev/null @@ -1,4 +0,0 @@ -b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03' -b'\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x07' -TypeError -TypeError diff --git a/tests/extmod/ticks_diff.py b/tests/extmod/ticks_diff.py index de45a557af..b2445f0d62 100644 --- a/tests/extmod/ticks_diff.py +++ b/tests/extmod/ticks_diff.py @@ -1,5 +1,5 @@ try: - from utime import ticks_diff, ticks_add + from time import ticks_diff, ticks_add except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/time_ms_us.py b/tests/extmod/time_ms_us.py index ac2ed8be27..67c469d0a3 100644 --- a/tests/extmod/time_ms_us.py +++ b/tests/extmod/time_ms_us.py @@ -1,23 +1,23 @@ try: - import utime + import time - utime.sleep_ms, utime.sleep_us, utime.ticks_diff, utime.ticks_ms, utime.ticks_us, utime.ticks_cpu + time.sleep_ms, time.sleep_us, time.ticks_diff, time.ticks_ms, time.ticks_us, time.ticks_cpu except (ImportError, AttributeError): print("SKIP") raise SystemExit -utime.sleep_ms(1) -utime.sleep_us(1) +time.sleep_ms(1) +time.sleep_us(1) -t0 = utime.ticks_ms() -t1 = utime.ticks_ms() -print(0 <= utime.ticks_diff(t1, t0) <= 1) +t0 = time.ticks_ms() +t1 = time.ticks_ms() +print(0 <= time.ticks_diff(t1, t0) <= 1) -t0 = utime.ticks_us() -t1 = utime.ticks_us() -print(0 <= utime.ticks_diff(t1, t0) <= 500) +t0 = time.ticks_us() +t1 = time.ticks_us() +print(0 <= time.ticks_diff(t1, t0) <= 500) -# ticks_cpu may not be implemented, at least make sure it doesn't decrease -t0 = utime.ticks_cpu() -t1 = utime.ticks_cpu() -print(utime.ticks_diff(t1, t0) >= 0) +# ticks_cpu may not be implemented, at least make sre it doesn't decrease +t0 = time.ticks_cpu() +t1 = time.ticks_cpu() +print(time.ticks_diff(t1, t0) >= 0) diff --git a/tests/extmod/uasyncio_await_return.py b/tests/extmod/uasyncio_await_return.py index 4a45d9b9c0..8042b5488d 100644 --- a/tests/extmod/uasyncio_await_return.py +++ b/tests/extmod/uasyncio_await_return.py @@ -1,13 +1,10 @@ # Test that tasks return their value correctly to the caller try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_basic.py b/tests/extmod/uasyncio_basic.py index baf9d193fe..148a361b4b 100644 --- a/tests/extmod/uasyncio_basic.py +++ b/tests/extmod/uasyncio_basic.py @@ -1,11 +1,8 @@ try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): @@ -19,10 +16,10 @@ except AttributeError: raise SystemExit try: - import utime + import time - ticks = utime.ticks_ms - ticks_diff = utime.ticks_diff + ticks = time.ticks_ms + ticks_diff = time.ticks_diff except: import time diff --git a/tests/extmod/uasyncio_basic2.py b/tests/extmod/uasyncio_basic2.py index a2167e48ee..3040b6aa51 100644 --- a/tests/extmod/uasyncio_basic2.py +++ b/tests/extmod/uasyncio_basic2.py @@ -1,11 +1,8 @@ try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def forever(): diff --git a/tests/extmod/uasyncio_cancel_fair.py b/tests/extmod/uasyncio_cancel_fair.py index 9a7b35c161..a1e35f82ba 100644 --- a/tests/extmod/uasyncio_cancel_fair.py +++ b/tests/extmod/uasyncio_cancel_fair.py @@ -2,13 +2,10 @@ # That tasks which continuously cancel each other don't take over the scheduler try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(id, other): diff --git a/tests/extmod/uasyncio_cancel_fair2.py b/tests/extmod/uasyncio_cancel_fair2.py index 46e40f71b1..577823204f 100644 --- a/tests/extmod/uasyncio_cancel_fair2.py +++ b/tests/extmod/uasyncio_cancel_fair2.py @@ -2,13 +2,10 @@ # That tasks which keeps being cancelled by multiple other tasks gets a chance to run try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task_a(): diff --git a/tests/extmod/uasyncio_cancel_self.py b/tests/extmod/uasyncio_cancel_self.py index 660ae66389..a437edb540 100644 --- a/tests/extmod/uasyncio_cancel_self.py +++ b/tests/extmod/uasyncio_cancel_self.py @@ -1,13 +1,10 @@ # Test a task cancelling itself (currently unsupported) try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(): diff --git a/tests/extmod/uasyncio_cancel_task.py b/tests/extmod/uasyncio_cancel_task.py index ec60d85545..9250f46b51 100644 --- a/tests/extmod/uasyncio_cancel_task.py +++ b/tests/extmod/uasyncio_cancel_task.py @@ -1,13 +1,10 @@ # Test cancelling a task try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(s, allow_cancel): diff --git a/tests/extmod/uasyncio_cancel_wait_on_finished.py b/tests/extmod/uasyncio_cancel_wait_on_finished.py index 66b36dd60d..c3529b8d7a 100644 --- a/tests/extmod/uasyncio_cancel_wait_on_finished.py +++ b/tests/extmod/uasyncio_cancel_wait_on_finished.py @@ -1,13 +1,10 @@ # Test cancelling a task that is waiting on a task that just finishes. try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def sleep_task(): diff --git a/tests/extmod/uasyncio_current_task.py b/tests/extmod/uasyncio_current_task.py index 3165a2cf16..18058230f2 100644 --- a/tests/extmod/uasyncio_current_task.py +++ b/tests/extmod/uasyncio_current_task.py @@ -1,13 +1,10 @@ # Test current_task() function try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(result): diff --git a/tests/extmod/uasyncio_event.py b/tests/extmod/uasyncio_event.py index fb8eb9ffa4..290323a7de 100644 --- a/tests/extmod/uasyncio_event.py +++ b/tests/extmod/uasyncio_event.py @@ -1,13 +1,10 @@ # Test Event class try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(id, ev): diff --git a/tests/extmod/uasyncio_event_fair.py b/tests/extmod/uasyncio_event_fair.py index 1eee0bd7e8..1029b54c5f 100644 --- a/tests/extmod/uasyncio_event_fair.py +++ b/tests/extmod/uasyncio_event_fair.py @@ -2,13 +2,10 @@ # That tasks which continuously wait on events don't take over the scheduler try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_exception.py b/tests/extmod/uasyncio_exception.py index 4e4f978dc2..6f19509bac 100644 --- a/tests/extmod/uasyncio_exception.py +++ b/tests/extmod/uasyncio_exception.py @@ -1,13 +1,10 @@ # Test general exception handling try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit # main task raising an exception diff --git a/tests/extmod/uasyncio_fair.py b/tests/extmod/uasyncio_fair.py index e225706054..43076fef1d 100644 --- a/tests/extmod/uasyncio_fair.py +++ b/tests/extmod/uasyncio_fair.py @@ -1,13 +1,10 @@ # Test fairness of scheduler try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(id, t): diff --git a/tests/extmod/uasyncio_gather.py b/tests/extmod/uasyncio_gather.py index e34176a31d..c666ff6b17 100644 --- a/tests/extmod/uasyncio_gather.py +++ b/tests/extmod/uasyncio_gather.py @@ -1,13 +1,10 @@ -# test uasyncio.gather() function +# test asyncio.gather() function try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_gather_notimpl.py b/tests/extmod/uasyncio_gather_notimpl.py index 63ba645d24..0b12bb804b 100644 --- a/tests/extmod/uasyncio_gather_notimpl.py +++ b/tests/extmod/uasyncio_gather_notimpl.py @@ -1,13 +1,10 @@ -# Test uasyncio.gather() function, features that are not implemented. +# Test asyncio.gather() function, featres that are not implemented. try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_get_event_loop.py b/tests/extmod/uasyncio_get_event_loop.py index 8ccbd6814e..b2d50e3cba 100644 --- a/tests/extmod/uasyncio_get_event_loop.py +++ b/tests/extmod/uasyncio_get_event_loop.py @@ -1,13 +1,10 @@ # Test get_event_loop() try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def main(): diff --git a/tests/extmod/uasyncio_heaplock.py b/tests/extmod/uasyncio_heaplock.py index 34a51cd370..482e7319ff 100644 --- a/tests/extmod/uasyncio_heaplock.py +++ b/tests/extmod/uasyncio_heaplock.py @@ -1,4 +1,4 @@ -# test that basic scheduling of tasks, and uasyncio.sleep_ms, does not use the heap +# test that basic scheduling of tasks, and asyncio.sleep_ms, does not use the heap import micropython @@ -13,13 +13,10 @@ except RuntimeError: raise SystemExit try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(id, n, t): diff --git a/tests/extmod/uasyncio_lock.py b/tests/extmod/uasyncio_lock.py index 096a8c82be..f565adb03f 100644 --- a/tests/extmod/uasyncio_lock.py +++ b/tests/extmod/uasyncio_lock.py @@ -1,13 +1,10 @@ # Test Lock class try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task_loop(id, lock): diff --git a/tests/extmod/uasyncio_lock_cancel.py b/tests/extmod/uasyncio_lock_cancel.py index 27428da80b..a501185e90 100644 --- a/tests/extmod/uasyncio_lock_cancel.py +++ b/tests/extmod/uasyncio_lock_cancel.py @@ -1,13 +1,10 @@ # Test that locks work when cancelling multiple waiters on the lock try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_loop_stop.py b/tests/extmod/uasyncio_loop_stop.py index 23507f9a7e..b4bd0c74ad 100644 --- a/tests/extmod/uasyncio_loop_stop.py +++ b/tests/extmod/uasyncio_loop_stop.py @@ -1,13 +1,10 @@ # Test Loop.stop() to stop the event loop try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(): diff --git a/tests/extmod/uasyncio_micropython.py b/tests/extmod/uasyncio_micropython.py index 69e5fa3224..c27a134cd9 100644 --- a/tests/extmod/uasyncio_micropython.py +++ b/tests/extmod/uasyncio_micropython.py @@ -3,7 +3,7 @@ # - wait_for_ms try: - import utime, uasyncio + import time, asyncio except ImportError: print("SKIP") raise SystemExit @@ -11,27 +11,27 @@ except ImportError: async def task(id, t): print("task start", id) - await uasyncio.sleep_ms(t) + await asyncio.sleep_ms(t) print("task end", id) return id * 2 async def main(): # Simple sleep_ms - t0 = utime.ticks_ms() - await uasyncio.sleep_ms(1) - print(utime.ticks_diff(utime.ticks_ms(), t0) < 100) + t0 = time.ticks_ms() + await asyncio.sleep_ms(1) + print(time.ticks_diff(time.ticks_ms(), t0) < 100) # When task finished before the timeout - print(await uasyncio.wait_for_ms(task(1, 5), 50)) + print(await asyncio.wait_for_ms(task(1, 5), 50)) # When timeout passes and task is cancelled try: - print(await uasyncio.wait_for_ms(task(2, 50), 5)) - except uasyncio.TimeoutError: + print(await asyncio.wait_for_ms(task(2, 50), 5)) + except asyncio.TimeoutError: print("timeout") print("finish") -uasyncio.run(main()) +asyncio.run(main()) diff --git a/tests/extmod/uasyncio_new_event_loop.py b/tests/extmod/uasyncio_new_event_loop.py index b711befba9..a3feb02126 100644 --- a/tests/extmod/uasyncio_new_event_loop.py +++ b/tests/extmod/uasyncio_new_event_loop.py @@ -1,13 +1,10 @@ # Test Loop.new_event_loop() try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(): diff --git a/tests/extmod/uasyncio_set_exception_handler.py b/tests/extmod/uasyncio_set_exception_handler.py index fe7b83eb4d..5935f0f4eb 100644 --- a/tests/extmod/uasyncio_set_exception_handler.py +++ b/tests/extmod/uasyncio_set_exception_handler.py @@ -1,13 +1,10 @@ # Test that tasks return their value correctly to the caller try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def custom_handler(loop, context): diff --git a/tests/extmod/uasyncio_task_done.py b/tests/extmod/uasyncio_task_done.py index 2700da8c34..7cc493a122 100644 --- a/tests/extmod/uasyncio_task_done.py +++ b/tests/extmod/uasyncio_task_done.py @@ -1,13 +1,10 @@ # Test the Task.done() method try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(t, exc=None): diff --git a/tests/extmod/uasyncio_task_exception.py b/tests/extmod/uasyncio_task_exception.py index 6bf99dc93c..9fb26857b5 100644 --- a/tests/extmod/uasyncio_task_exception.py +++ b/tests/extmod/uasyncio_task_exception.py @@ -8,13 +8,10 @@ # raising. try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def custom_handler(loop, context): diff --git a/tests/extmod/uasyncio_threadsafeflag.py b/tests/extmod/uasyncio_threadsafeflag.py index 4e002a3d2a..32eafae8bc 100644 --- a/tests/extmod/uasyncio_threadsafeflag.py +++ b/tests/extmod/uasyncio_threadsafeflag.py @@ -1,7 +1,7 @@ # Test Event class try: - import uasyncio as asyncio + import asyncio except ImportError: print("SKIP") raise SystemExit @@ -11,6 +11,7 @@ import micropython try: micropython.schedule + asyncio.ThreadSafeFlag except AttributeError: print("SKIP") raise SystemExit @@ -18,7 +19,7 @@ except AttributeError: try: # Unix port can't select/poll on user-defined types. - import uselect as select + import select poller = select.poll() poller.register(asyncio.ThreadSafeFlag()) diff --git a/tests/extmod/uasyncio_wait_for.py b/tests/extmod/uasyncio_wait_for.py index c636c7dd74..f973e46f4c 100644 --- a/tests/extmod/uasyncio_wait_for.py +++ b/tests/extmod/uasyncio_wait_for.py @@ -1,13 +1,10 @@ # Test asyncio.wait_for try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def task(id, t): diff --git a/tests/extmod/uasyncio_wait_for_fwd.py b/tests/extmod/uasyncio_wait_for_fwd.py index e608f63f6b..fd74ed01d5 100644 --- a/tests/extmod/uasyncio_wait_for_fwd.py +++ b/tests/extmod/uasyncio_wait_for_fwd.py @@ -1,13 +1,10 @@ # Test asyncio.wait_for, with forwarding cancellation try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit async def foo(): diff --git a/tests/extmod/uasyncio_wait_task.py b/tests/extmod/uasyncio_wait_task.py index e19e29903c..1b1762befe 100644 --- a/tests/extmod/uasyncio_wait_task.py +++ b/tests/extmod/uasyncio_wait_task.py @@ -1,20 +1,17 @@ # Test waiting on a task try: - import uasyncio as asyncio + import asyncio except ImportError: - try: - import asyncio - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: - import utime + import time - ticks = utime.ticks_ms - ticks_diff = utime.ticks_diff + ticks = time.ticks_ms + ticks_diff = time.ticks_diff except: import time diff --git a/tests/extmod/ubinascii_a2b_base64.py b/tests/extmod/ubinascii_a2b_base64.py index c65d69ddbe..f29330b6fc 100644 --- a/tests/extmod/ubinascii_a2b_base64.py +++ b/tests/extmod/ubinascii_a2b_base64.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_b2a_base64.py b/tests/extmod/ubinascii_b2a_base64.py index 34f2f57055..a6072d50ec 100644 --- a/tests/extmod/ubinascii_b2a_base64.py +++ b/tests/extmod/ubinascii_b2a_base64.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_crc32.py b/tests/extmod/ubinascii_crc32.py index 186bd699ae..b2f73d9475 100644 --- a/tests/extmod/ubinascii_crc32.py +++ b/tests/extmod/ubinascii_crc32.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_hexlify.py b/tests/extmod/ubinascii_hexlify.py index 3dcf0c4271..260010237c 100644 --- a/tests/extmod/ubinascii_hexlify.py +++ b/tests/extmod/ubinascii_hexlify.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_micropython.py b/tests/extmod/ubinascii_micropython.py index 94e8daa557..87c69b5838 100644 --- a/tests/extmod/ubinascii_micropython.py +++ b/tests/extmod/ubinascii_micropython.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ubinascii_unhexlify.py b/tests/extmod/ubinascii_unhexlify.py index f656bcd758..63994c11f1 100644 --- a/tests/extmod/ubinascii_unhexlify.py +++ b/tests/extmod/ubinascii_unhexlify.py @@ -1,8 +1,5 @@ try: - try: - import ubinascii as binascii - except ImportError: - import binascii + import binascii except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ucryptolib_aes128_cbc.py b/tests/extmod/ucryptolib_aes128_cbc.py deleted file mode 100644 index d861d2c6bf..0000000000 --- a/tests/extmod/ucryptolib_aes128_cbc.py +++ /dev/null @@ -1,16 +0,0 @@ -try: - from Crypto.Cipher import AES - - aes = AES.new -except ImportError: - try: - from ucryptolib import aes - except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 4, 2, b"5678" * 4) -enc = crypto.encrypt(bytes(range(32))) -print(enc) -crypto = aes(b"1234" * 4, 2, b"5678" * 4) -print(crypto.decrypt(enc)) diff --git a/tests/extmod/ucryptolib_aes128_cbc.py.exp b/tests/extmod/ucryptolib_aes128_cbc.py.exp deleted file mode 100644 index cc73553b2a..0000000000 --- a/tests/extmod/ucryptolib_aes128_cbc.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -b'\x1d\x84\xfa\xaa%\x0e9\x143\x8b6\xf8\xdf^yh\xd0\x94g\xf4\xcf\x1d\xa0I)\x8a\xa0\x00u0+C' -b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' diff --git a/tests/extmod/ucryptolib_aes128_ctr.py b/tests/extmod/ucryptolib_aes128_ctr.py deleted file mode 100644 index 538d9606e9..0000000000 --- a/tests/extmod/ucryptolib_aes128_ctr.py +++ /dev/null @@ -1,28 +0,0 @@ -try: - from ucryptolib import aes -except ImportError: - print("SKIP") - raise SystemExit - - -def _new(k, ctr_initial): - return aes(k, 6, ctr_initial) - - -try: - _new(b"x" * 16, b"x" * 16) -except ValueError as e: - # is CTR support disabled? - if e.args[0] == "mode": - print("SKIP") - raise SystemExit - raise e - -crypto = _new(b"1234" * 4, b"5678" * 4) -enc = crypto.encrypt(b"a") -print(enc) -enc += crypto.encrypt(b"b" * 1000) -print(enc) - -crypto = _new(b"1234" * 4, b"5678" * 4) -print(crypto.decrypt(enc)) diff --git a/tests/extmod/ucryptolib_aes128_ctr.py.exp b/tests/extmod/ucryptolib_aes128_ctr.py.exp deleted file mode 100644 index 92e090fd39..0000000000 --- a/tests/extmod/ucryptolib_aes128_ctr.py.exp +++ /dev/null @@ -1,3 +0,0 @@ -b'\x06' -b'\x06(F\x08\xc3hB\xfdO\x05;\xf6\x96\xfe\xad\xe0\xca\xe6\xd1\xa2m\t\x91v>|\xee\xe0q\xbc]\x9a`\xfal\x87\xa6e\xfb\x8a\xf4\xb2-\xc4x,\xfc@=,\x90\xf4\xe9h\xf0\xfc\xfb\xe6\x03\xf0d\xb6\xcdObZ\xde\x1b\xe2\x84-%=\xa9\xe4\x05\xab\xd7\x044\xf4$\xd0)\xfd\xd6\xdbL\xdd\xe6\x0cp\xca^p\xaaA\x8b\xb3!\xe3\x13\xfa\x7f#\xfa0\xbd\x0b\x9cX\xec\xed\x1c\xbc\x06\xa4\xa8\x17\xbfg\x98dW\xb9~\x04\xec\xe6lZ\xb0\xab\xd5\xc6v\xe4\x8f\x98G\xff\x9b\x8a\xae\xfd\xe5\xed\x96\x1b\xe2\x99u3\xeb\x9faYr;\xf0g\xf2\x9cq\x8dI\x1cL\xc9\xa8\xb0\xdeD\xd5\x06\x87u=\xcd\x10\x1c\xab\x14\x06n\x99\x13\x89\x9f5\xea\xd2\x08\x9e\xef$?\xb9\xdeQ\x0b\x90CH\xea@V\x94\x1a\xdd\x7f\x1dz\x82\xaay\xea$Lv\x07\x8e\xce\xb8oN\x15\xf8,\x05\x00\xd9H\xf4\xbe\xb8\xee\x0e\xd6Hjh\xc6\x11\xf8:\xfe\xed\xba_\xaf\x8e\'\x0c\x7fZ\xd5\xb7\xbc\xba\xd3+\xf1\x98i\xab\x0c-\xd9\xe6>\x9e\xd0\xe6>\x9f\xebn\xf0\x15\xd9:\xec\xf7aXa\xb2,CAB7\x18g\xcc#\xbc\xb8\xf9\xa7\xf4V\xba\x0baN\x88\xb1\xea\x94\x05\x0cV\x99_\xc4\xe6\xb2\xd1|\x92\x05*@U\xe4\\\x8dR\x98\xdf\xbfS\x97\x12^\tr\x1f\x12\x8f\xdfi\x8e=\xc4I\xfcB\r\x99f\xe3\xe31\xee\xa9\xcd\x91\x1a\x1ei\xfd\xf4\x84\xc6\xda\x9e\xf3\x8aKn\xaa\xf7\x9eS\xcc\xbaXZ\x0cpbk\x18\x1f\x9aAl>y\xad\xcb\xcf\xe1Wm\xe7\xdd\xcc\x10eW\xe4h\x1dY\xb5Zs\xf1\xe7\x16_\xdc:I1R\xd3\xfe\xb1)\t\xddE\xbax\x06R\xdc\x1dSdlu\xd1\x9c\x00\xaf\x87\x8d1\xbf$\x08\xc6/y\xdf\x1f\x97z(\xff\xb9\xcb\xf2,\x91\xd7\xa0W\xfc\xe3\xe2\x905\x17O\xaf\x18\xc7\xb8?\x94^\xf5@\x80\x8d\xaa*p\xbeR0i\x17\x1e\'-\xfa\xd9\xb2\x03\xb8\x1fY\x13\xc1{\x7f\xa9\x86\t\x99\xee\xa2\xba\xab\xc1\xbb\x07a\xa5J\x01\x98\xe8\x8e\xa1\x8aV\xc1)^A\xd9\xe7\xfej`\xb4\xe9\xd3C\xab\xd4\xdb\xb1\x8c\x83\xaa&\xf1\xe2\xfc\xa1Lb\xa8\xbb\xd6\x83\xb7\xd8\xc5\x9e\xb5\xed\x1b\xe6\x91\x90\xe4\xfa\xfdD\xc2\xcb\xb7U\xb3|?(\x86=\xc2\xff\xd3P\xd2\xc5y\x93\x13r\xcd>5\x80\xde\xdaJ\xdd\x8b\xfa\x14\xd1\x85\xa8P\x06(F\xb3?\xefm\x8e\xe5C\xfe\x98\xaf\xed\xd1!(\x1f.\xc6M\xba\x00\xcb\xbfg5\xc8\x9d\x97+\x14\x87\xf5\x9d4\xb4l\xd5\xc5>\x90\xf2\x06\xa2\xc1R\x89\xf0P\xb4\xe5\x97\xdb\x07\xd3\xc6q\x08\xb9\xe7\r\xf9\x13\x8215\xcb\x92\xed\x99\xc7"\x1e\xe3Zsh\x0e\xe7\xae\x10Xs&)\x1d\xe5\xd5\xbc\x95\x8e\xa3\xd6k[k\x9c\xa0%\xd4\x83%\x88}\x90\xf0\xa7\xc7\xa4(\xdaE\xb9~\xae\x05\xbd}\xe2\xd0\xa5Y\xc1aV[\xab\x93S\xa6\xacg\r\x14\xc6\xe2J\xd6\xcck"\xcc\xfb\xb3\x97\x14\x13\x0b\xd1\xf5\xe7)_\x1e\x0b\xbb\x01\xf7\x11u\x85b\xdf\xab\xe3\xbb:\x84zF\x14u\xfe\x89\x90\xbc\xcaF\x15y\xa3\xa4[\xce\xcf-\xae\x18\x97N\xaa\xed\x84A\xfc\x9e\xeb\xb3\xfcH\x8ej\xcc\x9f \x1b\xc1\x1f}\'q.\xc0^\xd99\x1e\x91b-\xf9\xed\xfd\x9a\x7f\xb6\rO\xea\xc8\x94\xea\xf6\xb4\xdb\xf5\xc7\xb3\xef\xf6D\x12>5\xf3\x9d*\xc9\xf8\x9f]\xb01{d\xe7\'\x8f\xc0\xfbKB\x8dd\xb1\x84\x804\xbe\xe2?AT\x14\xdb4eJ\x96\xc5\xb9%\xe5\x1c\xc0L\xae\xd6O\xde\x1fjJIRD\x96\xa2\xdb\xfc\xc6t\xce\xe6\xe8"\x81\xe6\xc7\x7fuz\xb3\x91\'D\xac\xb2\x93O\xee\x14\xaa7yT\xcf\x81p\x0b(\xa1d\xda\xf8\xcb\x01\x98\x07\'\xfe/\xe4\xca\xab\x03uR"zY\xfb\x1f\x02\xc5\x9c\xa0\'\x89\xffO\x88cK\xac\xb1+S0]%E\x1a\xeb\x04\xf7\x0b\xba\xa0\xbb\xbd|\x06@T\xee\xe7\x17\xa1T\xe3"\x07\x07q' -b'abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' diff --git a/tests/extmod/ucryptolib_aes128_ecb.py b/tests/extmod/ucryptolib_aes128_ecb.py deleted file mode 100644 index 5c0e179986..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb.py +++ /dev/null @@ -1,16 +0,0 @@ -try: - from Crypto.Cipher import AES - - aes = AES.new -except ImportError: - try: - from ucryptolib import aes - except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 4, 1) -enc = crypto.encrypt(bytes(range(32))) -print(enc) -crypto = aes(b"1234" * 4, 1) -print(crypto.decrypt(enc)) diff --git a/tests/extmod/ucryptolib_aes128_ecb.py.exp b/tests/extmod/ucryptolib_aes128_ecb.py.exp deleted file mode 100644 index b0fd15b447..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -b'Iz\xfe9\x17\xac\xa4X\x12\x04\x10\xf5K~#\xc7\xac;\xf9\xc6E\xa8\xca~\xf1\xee\xd3f%\xf1\x8d\xfe' -b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' diff --git a/tests/extmod/ucryptolib_aes128_ecb_enc.py b/tests/extmod/ucryptolib_aes128_ecb_enc.py deleted file mode 100644 index 1d4484b0bc..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_enc.py +++ /dev/null @@ -1,17 +0,0 @@ -# This tests minimal configuration of ucrypto module, which is -# AES128 encryption (anything else, including AES128 decryption, -# is optional). -try: - from Crypto.Cipher import AES - - aes = AES.new -except ImportError: - try: - from ucryptolib import aes - except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 4, 1) -enc = crypto.encrypt(bytes(range(32))) -print(enc) diff --git a/tests/extmod/ucryptolib_aes128_ecb_enc.py.exp b/tests/extmod/ucryptolib_aes128_ecb_enc.py.exp deleted file mode 100644 index 9921d4b83a..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_enc.py.exp +++ /dev/null @@ -1 +0,0 @@ -b'Iz\xfe9\x17\xac\xa4X\x12\x04\x10\xf5K~#\xc7\xac;\xf9\xc6E\xa8\xca~\xf1\xee\xd3f%\xf1\x8d\xfe' diff --git a/tests/extmod/ucryptolib_aes128_ecb_inpl.py b/tests/extmod/ucryptolib_aes128_ecb_inpl.py deleted file mode 100644 index 88ccb02daf..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_inpl.py +++ /dev/null @@ -1,15 +0,0 @@ -# Inplace operations (input and output buffer is the same) -try: - from ucryptolib import aes -except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 4, 1) -buf = bytearray(bytes(range(32))) -crypto.encrypt(buf, buf) -print(buf) - -crypto = aes(b"1234" * 4, 1) -crypto.decrypt(buf, buf) -print(buf) diff --git a/tests/extmod/ucryptolib_aes128_ecb_inpl.py.exp b/tests/extmod/ucryptolib_aes128_ecb_inpl.py.exp deleted file mode 100644 index b7f7bf5409..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_inpl.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -bytearray(b'Iz\xfe9\x17\xac\xa4X\x12\x04\x10\xf5K~#\xc7\xac;\xf9\xc6E\xa8\xca~\xf1\xee\xd3f%\xf1\x8d\xfe') -bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f') diff --git a/tests/extmod/ucryptolib_aes128_ecb_into.py b/tests/extmod/ucryptolib_aes128_ecb_into.py deleted file mode 100644 index ff832d7ef3..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_into.py +++ /dev/null @@ -1,16 +0,0 @@ -# Operations with pre-allocated output buffer -try: - from ucryptolib import aes -except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 4, 1) -enc = bytearray(32) -crypto.encrypt(bytes(range(32)), enc) -print(enc) - -crypto = aes(b"1234" * 4, 1) -dec = bytearray(32) -crypto.decrypt(enc, dec) -print(dec) diff --git a/tests/extmod/ucryptolib_aes128_ecb_into.py.exp b/tests/extmod/ucryptolib_aes128_ecb_into.py.exp deleted file mode 100644 index b7f7bf5409..0000000000 --- a/tests/extmod/ucryptolib_aes128_ecb_into.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -bytearray(b'Iz\xfe9\x17\xac\xa4X\x12\x04\x10\xf5K~#\xc7\xac;\xf9\xc6E\xa8\xca~\xf1\xee\xd3f%\xf1\x8d\xfe') -bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f') diff --git a/tests/extmod/ucryptolib_aes256_cbc.py b/tests/extmod/ucryptolib_aes256_cbc.py deleted file mode 100644 index c01846f199..0000000000 --- a/tests/extmod/ucryptolib_aes256_cbc.py +++ /dev/null @@ -1,16 +0,0 @@ -try: - from Crypto.Cipher import AES - - aes = AES.new -except ImportError: - try: - from ucryptolib import aes - except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 8, 2, b"5678" * 4) -enc = crypto.encrypt(bytes(range(32))) -print(enc) -crypto = aes(b"1234" * 8, 2, b"5678" * 4) -print(crypto.decrypt(enc)) diff --git a/tests/extmod/ucryptolib_aes256_cbc.py.exp b/tests/extmod/ucryptolib_aes256_cbc.py.exp deleted file mode 100644 index 51262db9c6..0000000000 --- a/tests/extmod/ucryptolib_aes256_cbc.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -b'\xb4\x0b\xff\xdd\xfc\xb5\x03\x88[m\xc1\x01+:\x03M\x18\xb03\x0f\x971g\x10\xb1\x98>\x9b\x17\xb7-\xb2' -b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' diff --git a/tests/extmod/ucryptolib_aes256_ecb.py b/tests/extmod/ucryptolib_aes256_ecb.py deleted file mode 100644 index 0760063c14..0000000000 --- a/tests/extmod/ucryptolib_aes256_ecb.py +++ /dev/null @@ -1,16 +0,0 @@ -try: - from Crypto.Cipher import AES - - aes = AES.new -except ImportError: - try: - from ucryptolib import aes - except ImportError: - print("SKIP") - raise SystemExit - -crypto = aes(b"1234" * 8, 1) -enc = crypto.encrypt(bytes(range(32))) -print(enc) -crypto = aes(b"1234" * 8, 1) -print(crypto.decrypt(enc)) diff --git a/tests/extmod/ucryptolib_aes256_ecb.py.exp b/tests/extmod/ucryptolib_aes256_ecb.py.exp deleted file mode 100644 index a00a4eb2f5..0000000000 --- a/tests/extmod/ucryptolib_aes256_ecb.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -b'\xe2\xe0\xdd\xef\xc3\xcd\x88/!>\xf6\xa2\xef/\xd15z+`\xb2\xb2\xd7}!:V>\xeb\x19\xbf|\xea' -b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' diff --git a/tests/extmod/uctypes_sizeof_od.py b/tests/extmod/uctypes_sizeof_od.py index 2f070095b5..375f05f5e2 100644 --- a/tests/extmod/uctypes_sizeof_od.py +++ b/tests/extmod/uctypes_sizeof_od.py @@ -1,5 +1,5 @@ try: - from ucollections import OrderedDict + from collections import OrderedDict import uctypes except ImportError: print("SKIP") diff --git a/tests/extmod/uhashlib_final.py b/tests/extmod/uhashlib_final.py index f562cc1780..c8fdac9234 100644 --- a/tests/extmod/uhashlib_final.py +++ b/tests/extmod/uhashlib_final.py @@ -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 diff --git a/tests/extmod/uhashlib_md5.py b/tests/extmod/uhashlib_md5.py index 07d5f31692..5f925fc97d 100644 --- a/tests/extmod/uhashlib_md5.py +++ b/tests/extmod/uhashlib_md5.py @@ -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 try: hashlib.md5 diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py index e6e6e30dc1..882f570843 100644 --- a/tests/extmod/uhashlib_sha1.py +++ b/tests/extmod/uhashlib_sha1.py @@ -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 try: hashlib.sha1 diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/uhashlib_sha256.py index 5c6dfd0a75..a0629dbc47 100644 --- a/tests/extmod/uhashlib_sha256.py +++ b/tests/extmod/uhashlib_sha256.py @@ -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() diff --git a/tests/extmod/uheapq1.py b/tests/extmod/uheapq1.py index a470bb6f71..efe208dac3 100644 --- a/tests/extmod/uheapq1.py +++ b/tests/extmod/uheapq1.py @@ -1,11 +1,8 @@ try: - import uheapq as heapq -except: - try: - import heapq - except ImportError: - print("SKIP") - raise SystemExit + import heapq +except ImportError: + print("SKIP") + raise SystemExit try: heapq.heappop([]) diff --git a/tests/extmod/ujson_dump.py b/tests/extmod/ujson_dump.py index feda8a47dd..897d33cc81 100644 --- a/tests/extmod/ujson_dump.py +++ b/tests/extmod/ujson_dump.py @@ -1,13 +1,9 @@ try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit s = StringIO() json.dump(False, s) diff --git a/tests/extmod/ujson_dump_iobase.py b/tests/extmod/ujson_dump_iobase.py index 7ecf23afb6..94d317b879 100644 --- a/tests/extmod/ujson_dump_iobase.py +++ b/tests/extmod/ujson_dump_iobase.py @@ -1,14 +1,10 @@ -# test ujson.dump in combination with uio.IOBase +# test json.dump in combination with io.IOBase try: - import uio as io - import ujson as json + import io, json except ImportError: - try: - import io, json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit if not hasattr(io, "IOBase"): print("SKIP") diff --git a/tests/extmod/ujson_dump_separators.py b/tests/extmod/ujson_dump_separators.py index e19b99a26d..4f8e56dceb 100644 --- a/tests/extmod/ujson_dump_separators.py +++ b/tests/extmod/ujson_dump_separators.py @@ -1,13 +1,9 @@ try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit for sep in [ None, diff --git a/tests/extmod/ujson_dumps.py b/tests/extmod/ujson_dumps.py index 251b268755..16f144e44f 100644 --- a/tests/extmod/ujson_dumps.py +++ b/tests/extmod/ujson_dumps.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.dumps(False)) print(json.dumps(True)) diff --git a/tests/extmod/ujson_dumps_extra.py b/tests/extmod/ujson_dumps_extra.py index f2aa7f249f..9074416a99 100644 --- a/tests/extmod/ujson_dumps_extra.py +++ b/tests/extmod/ujson_dumps_extra.py @@ -1,9 +1,9 @@ -# test uPy ujson behaviour that's not valid in CPy +# test uPy json behaviour that's not valid in CPy try: - import ujson + import json except ImportError: print("SKIP") raise SystemExit -print(ujson.dumps(b"1234")) +print(json.dumps(b"1234")) diff --git a/tests/extmod/ujson_dumps_float.py b/tests/extmod/ujson_dumps_float.py index 25681d0c23..25fbc5c512 100644 --- a/tests/extmod/ujson_dumps_float.py +++ b/tests/extmod/ujson_dumps_float.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.dumps(1.2)) print(json.dumps({1.5: "hi"})) diff --git a/tests/extmod/ujson_dumps_ordereddict.py b/tests/extmod/ujson_dumps_ordereddict.py index c6f4a8fcb7..e1fa2a659c 100644 --- a/tests/extmod/ujson_dumps_ordereddict.py +++ b/tests/extmod/ujson_dumps_ordereddict.py @@ -1,12 +1,8 @@ try: - import ujson as json - from ucollections import OrderedDict + import json + from collections import OrderedDict except ImportError: - try: - import json - from collections import OrderedDict - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.dumps(OrderedDict(((1, 2), (3, 4))))) diff --git a/tests/extmod/ujson_dumps_separators.py b/tests/extmod/ujson_dumps_separators.py index efb541fe8b..a3a9ec308f 100644 --- a/tests/extmod/ujson_dumps_separators.py +++ b/tests/extmod/ujson_dumps_separators.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit for sep in [ None, diff --git a/tests/extmod/ujson_load.py b/tests/extmod/ujson_load.py index 7cec9246b8..b2c7733282 100644 --- a/tests/extmod/ujson_load.py +++ b/tests/extmod/ujson_load.py @@ -1,13 +1,9 @@ try: - from uio import StringIO - import ujson as json -except: - try: - from io import StringIO - import json - except ImportError: - print("SKIP") - raise SystemExit + from io import StringIO + import json +except ImportError: + print("SKIP") + raise SystemExit print(json.load(StringIO("null"))) print(json.load(StringIO('"abc\\u0064e"'))) diff --git a/tests/extmod/ujson_load_readinto.py b/tests/extmod/ujson_load_readinto.py index 001aa4fb2c..25e5c6cc0c 100644 --- a/tests/extmod/ujson_load_readinto.py +++ b/tests/extmod/ujson_load_readinto.py @@ -1,4 +1,4 @@ -import ujson as json +import json # Test that json can load from any object with readinto diff --git a/tests/extmod/ujson_loads.py b/tests/extmod/ujson_loads.py index 2de9cdcbc1..f9073c121e 100644 --- a/tests/extmod/ujson_loads.py +++ b/tests/extmod/ujson_loads.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def my_print(o): diff --git a/tests/extmod/ujson_loads_bytes.py b/tests/extmod/ujson_loads_bytes.py index 3ee87bbcd5..45cd0a35c5 100644 --- a/tests/extmod/ujson_loads_bytes.py +++ b/tests/extmod/ujson_loads_bytes.py @@ -1,13 +1,10 @@ # test loading from bytes and bytearray (introduced in Python 3.6) try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit print(json.loads(b"[1,2]")) print(json.loads(bytearray(b"[null]"))) diff --git a/tests/extmod/ujson_loads_float.py b/tests/extmod/ujson_loads_float.py index 842718f37d..2a8402dc6a 100644 --- a/tests/extmod/ujson_loads_float.py +++ b/tests/extmod/ujson_loads_float.py @@ -1,11 +1,8 @@ try: - import ujson as json + import json except ImportError: - try: - import json - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def my_print(o): diff --git a/tests/extmod/umsgpack_pack.py b/tests/extmod/umsgpack_pack.py index 7ea5ae8d6a..511ee642dd 100644 --- a/tests/extmod/umsgpack_pack.py +++ b/tests/extmod/umsgpack_pack.py @@ -1,13 +1,9 @@ try: - from uio import BytesIO - import umsgpack as msgpack -except: - try: - from io import BytesIO - import msgpack - except ImportError: - print("SKIP") - raise SystemExit + from io import BytesIO + import msgpack +except ImportError: + print("SKIP") + raise SystemExit b = BytesIO() msgpack.pack(False, s) diff --git a/tests/extmod/urandom_basic.py b/tests/extmod/urandom_basic.py index f7f5a6d691..e42373e30d 100644 --- a/tests/extmod/urandom_basic.py +++ b/tests/extmod/urandom_basic.py @@ -1,5 +1,5 @@ try: - import urandom as random + import random except ImportError: try: import random diff --git a/tests/extmod/urandom_extra.py b/tests/extmod/urandom_extra.py index 78e17379dc..aa05053377 100644 --- a/tests/extmod/urandom_extra.py +++ b/tests/extmod/urandom_extra.py @@ -1,11 +1,8 @@ try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.randint diff --git a/tests/extmod/urandom_extra_float.py b/tests/extmod/urandom_extra_float.py index 65918da136..3b37ed8dce 100644 --- a/tests/extmod/urandom_extra_float.py +++ b/tests/extmod/urandom_extra_float.py @@ -1,11 +1,8 @@ try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.randint diff --git a/tests/extmod/urandom_seed_default.py b/tests/extmod/urandom_seed_default.py index a032b9362b..241649c14b 100644 --- a/tests/extmod/urandom_seed_default.py +++ b/tests/extmod/urandom_seed_default.py @@ -1,13 +1,10 @@ # test urandom.seed() without any arguments try: - import urandom as random + import random except ImportError: - try: - import random - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: random.seed() diff --git a/tests/extmod/ure1.py b/tests/extmod/ure1.py index a75b2e8b70..32a71acc21 100644 --- a/tests/extmod/ure1.py +++ b/tests/extmod/ure1.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit r = re.compile(".+") m = r.match("abc") diff --git a/tests/extmod/ure_debug.py b/tests/extmod/ure_debug.py index 7a07ede2d4..0f4c95551f 100644 --- a/tests/extmod/ure_debug.py +++ b/tests/extmod/ure_debug.py @@ -1,10 +1,10 @@ # test printing debugging info when compiling try: - import ure + import re - ure.DEBUG + re.DEBUG except (ImportError, AttributeError): print("SKIP") raise SystemExit -ure.compile("^a|b[0-9]\w$", ure.DEBUG) +re.compile("^a|b[0-9]\w$", re.DEBUG) diff --git a/tests/extmod/ure_error.py b/tests/extmod/ure_error.py index 52a96b7c03..f61d091328 100644 --- a/tests/extmod/ure_error.py +++ b/tests/extmod/ure_error.py @@ -1,13 +1,10 @@ # test errors in regex try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def test_re(r): diff --git a/tests/extmod/ure_group.py b/tests/extmod/ure_group.py index 41425dd623..06c9ccfb2d 100644 --- a/tests/extmod/ure_group.py +++ b/tests/extmod/ure_group.py @@ -1,13 +1,10 @@ # test groups, and nested groups try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def print_groups(match): diff --git a/tests/extmod/ure_groups.py b/tests/extmod/ure_groups.py index 7da072a920..840a4b1af1 100644 --- a/tests/extmod/ure_groups.py +++ b/tests/extmod/ure_groups.py @@ -1,13 +1,10 @@ # test match.groups() try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: m = re.match(".", "a") diff --git a/tests/extmod/ure_limit.py b/tests/extmod/ure_limit.py index 99c6a818e8..e0531afbdc 100644 --- a/tests/extmod/ure_limit.py +++ b/tests/extmod/ure_limit.py @@ -1,7 +1,7 @@ -# Test overflow in ure.compile output code. +# Test overflow in re.compile output code. try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_namedclass.py b/tests/extmod/ure_namedclass.py index 00d58ad98a..d2df7f23af 100644 --- a/tests/extmod/ure_namedclass.py +++ b/tests/extmod/ure_namedclass.py @@ -1,13 +1,10 @@ # test named char classes try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit def print_groups(match): diff --git a/tests/extmod/ure_span.py b/tests/extmod/ure_span.py index 03a3fef9f3..d00ef957a1 100644 --- a/tests/extmod/ure_span.py +++ b/tests/extmod/ure_span.py @@ -1,13 +1,10 @@ # test match.span(), and nested spans try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: m = re.match(".", "a") diff --git a/tests/extmod/ure_split.py b/tests/extmod/ure_split.py index 7e6ef3990f..7769e1a121 100644 --- a/tests/extmod/ure_split.py +++ b/tests/extmod/ure_split.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit r = re.compile(" ") s = r.split("a b c foobar") diff --git a/tests/extmod/ure_split_empty.py b/tests/extmod/ure_split_empty.py index 76ce97ea67..d386672308 100644 --- a/tests/extmod/ure_split_empty.py +++ b/tests/extmod/ure_split_empty.py @@ -1,11 +1,11 @@ # test splitting with pattern matches that can be empty # -# CPython 3.5 issues a FutureWarning for these tests because their -# behaviour will change in a future version. MicroPython just stops +# CPython 3.5 issues a FutreWarning for these tests because their +# behaviour will change in a futre version. MicroPython just stops # splitting as soon as an empty match is found. try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_split_notimpl.py b/tests/extmod/ure_split_notimpl.py index 51bad791ef..7ddec9fa03 100644 --- a/tests/extmod/ure_split_notimpl.py +++ b/tests/extmod/ure_split_notimpl.py @@ -1,5 +1,5 @@ try: - import ure as re + import re except ImportError: print("SKIP") raise SystemExit diff --git a/tests/extmod/ure_stack_overflow.py b/tests/extmod/ure_stack_overflow.py index d3ce0c5a7b..90fb8296b1 100644 --- a/tests/extmod/ure_stack_overflow.py +++ b/tests/extmod/ure_stack_overflow.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: re.match("(a*)*", "aaa") diff --git a/tests/extmod/ure_sub.py b/tests/extmod/ure_sub.py index 806c389576..253b2dc482 100644 --- a/tests/extmod/ure_sub.py +++ b/tests/extmod/ure_sub.py @@ -1,11 +1,8 @@ try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: re.sub @@ -76,6 +73,6 @@ except TypeError: # Include \ in the sub replacement print(re.sub("b", "\\\\b", "abc")) -# Using ^, make sure it doesn't repeatedly match +# Using ^, make sre it doesn't repeatedly match print(re.sub("^ab", "*", "abababcabab")) print(re.sub("^ab|cab", "*", "abababcabab")) diff --git a/tests/extmod/ure_sub_unmatched.py b/tests/extmod/ure_sub_unmatched.py index d6312bfc2c..c238a7ed64 100644 --- a/tests/extmod/ure_sub_unmatched.py +++ b/tests/extmod/ure_sub_unmatched.py @@ -1,13 +1,10 @@ # test re.sub with unmatched groups, behaviour changed in CPython 3.5 try: - import ure as re + import re except ImportError: - try: - import re - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: re.sub diff --git a/tests/extmod/uselect_poll_basic.py b/tests/extmod/uselect_poll_basic.py deleted file mode 100644 index 97fbd6fd15..0000000000 --- a/tests/extmod/uselect_poll_basic.py +++ /dev/null @@ -1,42 +0,0 @@ -try: - import usocket as socket, uselect as select, uerrno as errno -except ImportError: - try: - import socket, select, errno - - select.poll # Raises AttributeError for CPython implementations without poll() - except (ImportError, AttributeError): - print("SKIP") - raise SystemExit - - -poller = select.poll() - -s = socket.socket() - -poller.register(s) -# https://docs.python.org/3/library/select.html#select.poll.register -# "Registering a file descriptor that’s already registered is not an error, -# and has the same effect as registering the descriptor exactly once." -poller.register(s) - -# 2 args are mandatory unlike register() -try: - poller.modify(s) -except TypeError: - print("modify:TypeError") - -poller.modify(s, select.POLLIN) - -poller.unregister(s) - -try: - poller.modify(s, select.POLLIN) -except OSError as e: - assert e.errno == errno.ENOENT - -# poll after closing the socket, should return POLLNVAL -poller.register(s) -s.close() -p = poller.poll(0) -print(len(p), p[0][-1]) diff --git a/tests/extmod/uselect_poll_udp.py b/tests/extmod/uselect_poll_udp.py deleted file mode 100644 index 2a56a122b5..0000000000 --- a/tests/extmod/uselect_poll_udp.py +++ /dev/null @@ -1,30 +0,0 @@ -# test select.poll on UDP sockets - -try: - import usocket as socket, uselect as select -except ImportError: - try: - import socket, select - - select.poll # Raises AttributeError for CPython implementations without poll() - except (ImportError, AttributeError): - print("SKIP") - raise SystemExit - - -s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -s.bind(socket.getaddrinfo("127.0.0.1", 8000)[0][-1]) -poll = select.poll() - -# UDP socket should not be readable -poll.register(s, select.POLLIN) -print(len(poll.poll(0))) - -# UDP socket should be writable -poll.modify(s, select.POLLOUT) -print(poll.poll(0)[0][1] == select.POLLOUT) - -# same test for select.select, but just skip it if the function isn't available -if hasattr(select, "select"): - r, w, e = select.select([s], [], [], 0) - assert not r and not w and not e diff --git a/tests/extmod/usocket_tcp_basic.py b/tests/extmod/usocket_tcp_basic.py deleted file mode 100644 index c2fe8cd14c..0000000000 --- a/tests/extmod/usocket_tcp_basic.py +++ /dev/null @@ -1,17 +0,0 @@ -# Test basic, stand-alone TCP socket functionality - -try: - import usocket as socket, uerrno as errno -except ImportError: - try: - import socket, errno - except ImportError: - print("SKIP") - raise SystemExit - -# recv() on a fresh socket should raise ENOTCONN -s = socket.socket() -try: - s.recv(1) -except OSError as er: - print("ENOTCONN:", er.errno == errno.ENOTCONN) diff --git a/tests/extmod/usocket_udp_nonblock.py b/tests/extmod/usocket_udp_nonblock.py deleted file mode 100644 index bc560de142..0000000000 --- a/tests/extmod/usocket_udp_nonblock.py +++ /dev/null @@ -1,20 +0,0 @@ -# test non-blocking UDP sockets - -try: - import usocket as socket, uerrno as errno -except ImportError: - try: - import socket, errno - except ImportError: - print("SKIP") - raise SystemExit - - -s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -s.bind(socket.getaddrinfo("127.0.0.1", 8000)[0][-1]) -s.settimeout(0) - -try: - s.recv(1) -except OSError as er: - print("EAGAIN:", er.errno == errno.EAGAIN) diff --git a/tests/extmod/ussl_basic.py b/tests/extmod/ussl_basic.py deleted file mode 100644 index 9e1821dca9..0000000000 --- a/tests/extmod/ussl_basic.py +++ /dev/null @@ -1,60 +0,0 @@ -# very basic test of ssl module, just to test the methods exist - -try: - import uio as io - import ussl as ssl -except ImportError: - print("SKIP") - raise SystemExit - -# create in client mode -try: - ss = ssl.wrap_socket(io.BytesIO(), server_hostname="test.example.com") -except OSError as er: - print("wrap_socket:", repr(er)) - -# create in server mode (can use this object for further tests) -socket = io.BytesIO() -ss = ssl.wrap_socket(socket, server_side=1) - -# print -print(repr(ss)[:12]) - -# setblocking() propagates call to the underlying stream object, and -# io.BytesIO doesn't have setblocking() (in CPython too). -# try: -# ss.setblocking(False) -# except NotImplementedError: -# print('setblocking: NotImplementedError') -# ss.setblocking(True) - -# write -print(ss.write(b"aaaa")) - -# read (underlying socket has no data) -print(ss.read(8)) - -# read (underlying socket has data, but it's bad data) -socket.write(b"aaaaaaaaaaaaaaaa") -socket.seek(0) -try: - ss.read(8) -except OSError as er: - print("read:", repr(er)) - -# close -ss.close() -# close 2nd time -ss.close() - -# read on closed socket -try: - ss.read(10) -except OSError as er: - print("read:", repr(er)) - -# write on closed socket -try: - ss.write(b"aaaa") -except OSError as er: - print("write:", repr(er)) diff --git a/tests/extmod/ussl_basic.py.exp b/tests/extmod/ussl_basic.py.exp deleted file mode 100644 index eb7df855aa..0000000000 --- a/tests/extmod/ussl_basic.py.exp +++ /dev/null @@ -1,7 +0,0 @@ -wrap_socket: OSError(-256, 'CONN_LOST') -<_SSLSocket -4 -b'' -read: OSError(-261,) -read: OSError(9,) -write: OSError(9,) diff --git a/tests/extmod/ussl_keycert.py b/tests/extmod/ussl_keycert.py deleted file mode 100644 index 87a40a1e55..0000000000 --- a/tests/extmod/ussl_keycert.py +++ /dev/null @@ -1,28 +0,0 @@ -# Test ussl with key/cert passed in - -try: - import uio as io - import ussl as ssl -except ImportError: - print("SKIP") - raise SystemExit - -key = b"0\x82\x019\x02\x01\x00\x02A\x00\xf9\xe0}\xbd\xd7\x9cI\x18\x06\xc3\xcb\xb5\xec@r\xfbD\x18\x80\xaaWoZ{\xcc\xa3\xeb!\"\x0fY\x9e]-\xee\xe4\t!BY\x9f{7\xf3\xf2\x8f}}\r|.\xa8<\ta\xb2\xd7W\xb3\xc9\x19A\xc39\x02\x03\x01\x00\x01\x02@\x07:\x9fh\xa6\x9c6\xe1#\x10\xf7\x0b\xc4Q\xf9\x01\x9b\xee\xb9\x8a4\r\\\xa8\xc8:\xd5\xca\x97\x99\xaa\x16\x04)\xa8\xf9\x13\xdeq\x0ev`\xa7\x83\xc5\x8b`\xdb\xef \x9d\x93\xe8g\x84\x96\xfaV\\\xf4R\xda\xd0\xa1\x02!\x00\xfeR\xbf\n\x91Su\x87L\x98{\xeb%\xed\xfb\x06u)@\xfe\x1b\xde\xa0\xc6@\xab\xc5\xedg\x8e\x10[\x02!\x00\xfb\x86=\x85\xa4'\xde\x85\xb5L\xe0)\x99\xfaL\x8c3A\x02\xa8<\xdew\xad\x00\xe3\x1d\x05\xd8\xb4N\xfb\x02 \x08\xb0M\x04\x90hx\x88q\xcew\xd5U\xcbf\x9b\x16\xdf\x9c\xef\xd1\x85\xee\x9a7Ug\x02\xb0Z\x03'\x02 9\xa0D\xe2$|\xf9\xefz]5\x92rs\xb5+\xfd\xe6,\x1c\xadmn\xcf\xd5?3|\x0em)\x17\x02 5Z\xcc/\xa5?\n\x04%\x9b{N\x9dX\xddI\xbe\xd2\xb0\xa0\x03BQ\x02\x82\xc2\xe0u)\xbd\xb8\xaf" - -# Invalid key -try: - ssl.wrap_socket(io.BytesIO(), key=b"!") -except ValueError as er: - print(repr(er)) - -# Valid key, no cert -try: - ssl.wrap_socket(io.BytesIO(), key=key) -except TypeError as er: - print(repr(er)) - -# Valid key, invalid cert -try: - ssl.wrap_socket(io.BytesIO(), key=key, cert=b"!") -except ValueError as er: - print(repr(er)) diff --git a/tests/extmod/ussl_keycert.py.exp b/tests/extmod/ussl_keycert.py.exp deleted file mode 100644 index b72d319c6a..0000000000 --- a/tests/extmod/ussl_keycert.py.exp +++ /dev/null @@ -1,3 +0,0 @@ -ValueError('invalid key',) -TypeError("can't convert 'NoneType' object to str implicitly",) -ValueError('invalid cert',) diff --git a/tests/extmod/utime_res.py b/tests/extmod/utime_res.py index 4b62433483..548bef1f17 100644 --- a/tests/extmod/utime_res.py +++ b/tests/extmod/utime_res.py @@ -1,18 +1,18 @@ -# test utime resolutions +# test time resolutions try: - import utime + import time except ImportError: print("SKIP") raise SystemExit def gmtime_time(): - return utime.gmtime(utime.time()) + return time.gmtime(time.time()) def localtime_time(): - return utime.localtime(utime.time()) + return time.localtime(time.time()) def test(): @@ -32,12 +32,12 @@ def test(): # call time functions results_map = {} - end_time = utime.ticks_ms() + TEST_TIME - while utime.ticks_diff(end_time, utime.ticks_ms()) > 0: - utime.sleep_ms(100) + end_time = time.ticks_ms() + TEST_TIME + while time.ticks_diff(end_time, time.ticks_ms()) > 0: + time.sleep_ms(100) for func_name, _ in EXPECTED_MAP: try: - time_func = getattr(utime, func_name, None) or globals()[func_name] + time_func = getattr(time, func_name, None) or globals()[func_name] now = time_func() # may raise AttributeError except (KeyError, AttributeError): continue diff --git a/tests/extmod/utime_time_ns.py b/tests/extmod/utime_time_ns.py index 0d13f839d4..3ef58e56a9 100644 --- a/tests/extmod/utime_time_ns.py +++ b/tests/extmod/utime_time_ns.py @@ -1,18 +1,18 @@ -# test utime.time_ns() +# test time.time_ns() try: - import utime + import time - utime.sleep_us - utime.time_ns + time.sleep_us + time.time_ns except (ImportError, AttributeError): print("SKIP") raise SystemExit -t0 = utime.time_ns() -utime.sleep_us(5000) -t1 = utime.time_ns() +t0 = time.time_ns() +time.sleep_us(5000) +t1 = time.time_ns() # Check that time_ns increases. print(t0 < t1) diff --git a/tests/extmod/utimeq1.py b/tests/extmod/utimeq1.py deleted file mode 100644 index 688e5b834f..0000000000 --- a/tests/extmod/utimeq1.py +++ /dev/null @@ -1,146 +0,0 @@ -# Test for utimeq module which implements task queue with support for -# wraparound time (utime.ticks_ms() style). -try: - from utime import ticks_add, ticks_diff - from utimeq import utimeq -except ImportError: - print("SKIP") - raise SystemExit - -DEBUG = 0 - -MAX = ticks_add(0, -1) -MODULO_HALF = MAX // 2 + 1 - -if DEBUG: - - def dprint(*v): - print(*v) - -else: - - def dprint(*v): - pass - - -# Try not to crash on invalid data -h = utimeq(10) -try: - h.push(1) - assert False -except TypeError: - pass - -try: - h.pop(1) - assert False -except IndexError: - pass - -# unsupported unary op -try: - ~h - assert False -except TypeError: - pass - -# pushing on full queue -h = utimeq(1) -h.push(1, 0, 0) -try: - h.push(2, 0, 0) - assert False -except IndexError: - pass - -# popping into invalid type -try: - h.pop([]) - assert False -except TypeError: - pass - -# length -assert len(h) == 1 - -# peektime -assert h.peektime() == 1 - -# peektime with empty queue -try: - utimeq(1).peektime() - assert False -except IndexError: - pass - - -def pop_all(h): - l = [] - while h: - item = [0, 0, 0] - h.pop(item) - # print("!", item) - l.append(tuple(item)) - dprint(l) - return l - - -def add(h, v): - h.push(v, 0, 0) - dprint("-----") - # h.dump() - dprint("-----") - - -h = utimeq(10) -add(h, 0) -add(h, MAX) -add(h, MAX - 1) -add(h, 101) -add(h, 100) -add(h, MAX - 2) -dprint(h) -l = pop_all(h) -for i in range(len(l) - 1): - diff = ticks_diff(l[i + 1][0], l[i][0]) - assert diff > 0 - - -def edge_case(edge, offset): - h = utimeq(10) - add(h, ticks_add(0, offset)) - add(h, ticks_add(edge, offset)) - dprint(h) - l = pop_all(h) - diff = ticks_diff(l[1][0], l[0][0]) - dprint(diff, diff > 0) - return diff - - -dprint("===") -diff = edge_case(MODULO_HALF - 1, 0) -assert diff == MODULO_HALF - 1 -assert edge_case(MODULO_HALF - 1, 100) == diff -assert edge_case(MODULO_HALF - 1, -100) == diff - -# We expect diff to be always positive, per the definition of heappop() which should return -# the smallest value. -# This is the edge case where this invariant breaks, due to asymmetry of two's-complement -# range - there's one more negative integer than positive, so heappushing values like below -# will then make ticks_diff() return the minimum negative value. We could make heappop -# return them in a different order, but ticks_diff() result would be the same. Conclusion: -# never add to a heap values where (a - b) == MODULO_HALF (and which are >= MODULO_HALF -# ticks apart in real time of course). -dprint("===") -diff = edge_case(MODULO_HALF, 0) -assert diff == -MODULO_HALF -assert edge_case(MODULO_HALF, 100) == diff -assert edge_case(MODULO_HALF, -100) == diff - -dprint("===") -diff = edge_case(MODULO_HALF + 1, 0) -assert diff == MODULO_HALF - 1 -assert edge_case(MODULO_HALF + 1, 100) == diff -assert edge_case(MODULO_HALF + 1, -100) == diff - -print("OK") diff --git a/tests/extmod/utimeq1.py.exp b/tests/extmod/utimeq1.py.exp deleted file mode 100644 index d86bac9de5..0000000000 --- a/tests/extmod/utimeq1.py.exp +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/tests/extmod/utimeq_stable.py b/tests/extmod/utimeq_stable.py deleted file mode 100644 index 9fb522d514..0000000000 --- a/tests/extmod/utimeq_stable.py +++ /dev/null @@ -1,22 +0,0 @@ -try: - from utimeq import utimeq -except ImportError: - print("SKIP") - raise SystemExit - -h = utimeq(10) - -# Check that for 2 same-key items, the queue is stable (pops items -# in the same order they were pushed). Unfortunately, this no longer -# holds for more same-key values, as the underlying heap structure -# is not stable itself. -h.push(100, 20, 0) -h.push(100, 10, 0) - -res = [0, 0, 0] -h.pop(res) -assert res == [100, 20, 0] -h.pop(res) -assert res == [100, 10, 0] - -print("OK") diff --git a/tests/extmod/utimeq_stable.py.exp b/tests/extmod/utimeq_stable.py.exp deleted file mode 100644 index d86bac9de5..0000000000 --- a/tests/extmod/utimeq_stable.py.exp +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/tests/extmod/uzlib_decompio.py b/tests/extmod/uzlib_decompio.py index 6a0aae8bcd..ce3b7f4a99 100644 --- a/tests/extmod/uzlib_decompio.py +++ b/tests/extmod/uzlib_decompio.py @@ -1,10 +1,16 @@ try: - import uzlib as zlib - import uio as io + import zlib + import io except ImportError: print("SKIP") raise SystemExit +try: + zlib.decompIO +except AttributeError: + print("SKIP") + raise SystemExit + # Raw DEFLATE bitstream buf = io.BytesIO(b"\xcbH\xcd\xc9\xc9\x07\x00") diff --git a/tests/extmod/uzlib_decompio_gz.py b/tests/extmod/uzlib_decompio_gz.py index 1bc8ba885b..348bf2678d 100644 --- a/tests/extmod/uzlib_decompio_gz.py +++ b/tests/extmod/uzlib_decompio_gz.py @@ -1,10 +1,16 @@ try: - import uzlib as zlib - import uio as io + import zlib + import io except ImportError: print("SKIP") raise SystemExit +try: + zlib.decompIO +except AttributeError: + print("SKIP") + raise SystemExit + # gzip bitstream buf = io.BytesIO( diff --git a/tests/extmod/uzlib_decompress.py b/tests/extmod/uzlib_decompress.py index 8d4a9640b4..b72ee96ea8 100644 --- a/tests/extmod/uzlib_decompress.py +++ b/tests/extmod/uzlib_decompress.py @@ -1,11 +1,8 @@ try: import zlib except ImportError: - try: - import uzlib as zlib - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit PATTERNS = [ # Packed results produced by CPy's zlib.compress() diff --git a/tests/extmod/vfs_basic.py b/tests/extmod/vfs_basic.py index 9a9ef2ca61..028846406a 100644 --- a/tests/extmod/vfs_basic.py +++ b/tests/extmod/vfs_basic.py @@ -1,9 +1,9 @@ # test VFS functionality without any particular filesystem type try: - import uos + import os - uos.mount + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -59,35 +59,35 @@ class Filesystem: # first we umount any existing mount points the target may have try: - uos.umount("/") + os.umount("/") except OSError: pass -for path in uos.listdir("/"): - uos.umount("/" + path) +for path in os.listdir("/"): + os.umount("/" + path) # stat root dir -print(uos.stat("/")) +print(os.stat("/")) # statvfs root dir; verify that f_namemax has a sensible size -print(uos.statvfs("/")[9] >= 32) +print(os.statvfs("/")[9] >= 32) # getcwd when in root dir -print(uos.getcwd()) +print(os.getcwd()) # test operations on the root directory with nothing mounted, they should all fail for func in ("chdir", "listdir", "mkdir", "remove", "rmdir", "stat"): for arg in ("x", "/x"): try: - getattr(uos, func)(arg) + getattr(os, func)(arg) except OSError: print(func, arg, "OSError") # basic mounting and listdir -uos.mount(Filesystem(1), "/test_mnt") -print(uos.listdir()) +os.mount(Filesystem(1), "/test_mnt") +print(os.listdir()) # ilistdir -i = uos.ilistdir() +i = os.ilistdir() print(next(i)) try: next(i) @@ -99,88 +99,88 @@ except StopIteration: print("StopIteration") # referencing the mount point in different ways -print(uos.listdir("test_mnt")) -print(uos.listdir("/test_mnt")) +print(os.listdir("test_mnt")) +print(os.listdir("/test_mnt")) # mounting another filesystem -uos.mount(Filesystem(2), "/test_mnt2", readonly=True) -print(uos.listdir()) -print(uos.listdir("/test_mnt2")) +os.mount(Filesystem(2), "/test_mnt2", readonly=True) +print(os.listdir()) +print(os.listdir("/test_mnt2")) # mounting over an existing mount point try: - uos.mount(Filesystem(3), "/test_mnt2") + os.mount(Filesystem(3), "/test_mnt2") except OSError: print("OSError") # mkdir of a mount point try: - uos.mkdir("/test_mnt") + os.mkdir("/test_mnt") except OSError: print("OSError") # rename across a filesystem try: - uos.rename("/test_mnt/a", "/test_mnt2/b") + os.rename("/test_mnt/a", "/test_mnt2/b") except OSError: print("OSError") # delegating to mounted filesystem -uos.chdir("test_mnt") -print(uos.listdir()) -print(uos.getcwd()) -uos.mkdir("test_dir") -uos.remove("test_file") -uos.rename("test_file", "test_file2") -uos.rmdir("test_dir") -print(uos.stat("test_file")) -print(uos.statvfs("/test_mnt")) +os.chdir("test_mnt") +print(os.listdir()) +print(os.getcwd()) +os.mkdir("test_dir") +os.remove("test_file") +os.rename("test_file", "test_file2") +os.rmdir("test_dir") +print(os.stat("test_file")) +print(os.statvfs("/test_mnt")) open("test_file") open("test_file", "wb") # umount -uos.umount("/test_mnt") -uos.umount("/test_mnt2") +os.umount("/test_mnt") +os.umount("/test_mnt2") # umount a non-existent mount point try: - uos.umount("/test_mnt") + os.umount("/test_mnt") except OSError: print("OSError") # root dir -uos.mount(Filesystem(3), "/") -print(uos.stat("/")) -print(uos.statvfs("/")) -print(uos.listdir()) +os.mount(Filesystem(3), "/") +print(os.stat("/")) +print(os.statvfs("/")) +print(os.listdir()) open("test") -uos.mount(Filesystem(4), "/mnt") -print(uos.listdir()) -print(uos.listdir("/mnt")) -uos.chdir("/mnt") -print(uos.listdir()) +os.mount(Filesystem(4), "/mnt") +print(os.listdir()) +print(os.listdir("/mnt")) +os.chdir("/mnt") +print(os.listdir()) # chdir to a subdir within root-mounted vfs, and then listdir -uos.chdir("/subdir") -print(uos.listdir()) -uos.chdir("/") +os.chdir("/subdir") +print(os.listdir()) +os.chdir("/") -uos.umount("/") -print(uos.listdir("/")) -uos.umount("/mnt") +os.umount("/") +print(os.listdir("/")) +os.umount("/mnt") # chdir to a non-existent mount point (current directory should remain unchanged) try: - uos.chdir("/foo") + os.chdir("/foo") except OSError: print("OSError") -print(uos.getcwd()) +print(os.getcwd()) # chdir to a non-existent subdirectory in a mounted filesystem -uos.mount(Filesystem(5, 1), "/mnt") +os.mount(Filesystem(5, 1), "/mnt") try: - uos.chdir("/mnt/subdir") + os.chdir("/mnt/subdir") except OSError: print("OSError") -print(uos.getcwd()) +print(os.getcwd()) diff --git a/tests/extmod/vfs_blockdev.py b/tests/extmod/vfs_blockdev.py index e24169ba93..333ac7f183 100644 --- a/tests/extmod/vfs_blockdev.py +++ b/tests/extmod/vfs_blockdev.py @@ -1,10 +1,10 @@ # Test for behaviour of combined standard and extended block device try: - import uos + import os - uos.VfsFat - uos.VfsLfs2 + os.VfsFat + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -70,5 +70,5 @@ except MemoryError: print("SKIP") raise SystemExit -test(bdev, uos.VfsFat) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsFat) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_fat_case.py b/tests/extmod/vfs_fat_case.py index cb02264dcb..bf2c18ea69 100644 --- a/tests/extmod/vfs_fat_case.py +++ b/tests/extmod/vfs_fat_case.py @@ -1,8 +1,8 @@ -import errno as uerrno -import os as uos +import errno +import os as os try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -40,10 +40,10 @@ except MemoryError: print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") -uos.chdir("/ramdisk") +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") +os.chdir("/ramdisk") vfs.label = "labelæ" # This label would normally be LABELÆ but our limited upper casing does "LABELæ" @@ -51,22 +51,22 @@ print(vfs.label) # Check ASCII case-insensitivity vfs.mkdir("fooaz") -print(uos.listdir("")) +print(os.listdir("")) vfs.rmdir("fOOAZ") # Check ASCII case-insensitivity for long names (8+ characters) vfs.mkdir("123456789fooaz") -print(uos.listdir("")) +print(os.listdir("")) vfs.rmdir("123456789fOOAZ") # Characters outside of a-z are case sensitive. vfs.mkdir("extended_æ") -print(uos.listdir("")) +print(os.listdir("")) # Normally this would work ok. With our limited uppercasing, it won't. try: vfs.rmdir("extended_Æ") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) vfs.rmdir("extended_æ") diff --git a/tests/extmod/vfs_fat_fileio1.py b/tests/extmod/vfs_fat_fileio1.py index 935f01d24f..3bc85af9f8 100644 --- a/tests/extmod/vfs_fat_fileio1.py +++ b/tests/extmod/vfs_fat_fileio1.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -43,10 +43,10 @@ except MemoryError: print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") -uos.chdir("/ramdisk") +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") +os.chdir("/ramdisk") # file IO f = open("foo_file.txt", "w") @@ -58,22 +58,22 @@ f.close() # allowed try: f.write("world!") except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: f.read() except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: f.flush() except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) try: open("foo_file.txt", "x") except OSError as e: - print(e.errno == uerrno.EEXIST) + print(e.errno == errno.EEXIST) with open("foo_file.txt", "a") as f: f.write("world!") @@ -105,7 +105,7 @@ vfs.mkdir("foo_dir") try: vfs.rmdir("foo_file.txt") except OSError as e: - print(e.errno == 20) # uerrno.ENOTDIR + print(e.errno == 20) # errno.ENOTDIR vfs.remove("foo_file.txt") print(list(vfs.ilistdir())) diff --git a/tests/extmod/vfs_fat_fileio2.py b/tests/extmod/vfs_fat_fileio2.py index 6094b5a6f1..e243f2839b 100644 --- a/tests/extmod/vfs_fat_fileio2.py +++ b/tests/extmod/vfs_fat_fileio2.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -44,35 +44,35 @@ except MemoryError: print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") -uos.chdir("/ramdisk") +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") +os.chdir("/ramdisk") try: vfs.mkdir("foo_dir") except OSError as e: - print(e.errno == uerrno.EEXIST) + print(e.errno == errno.EEXIST) try: vfs.remove("foo_dir") except OSError as e: - print(e.errno == uerrno.EISDIR) + print(e.errno == errno.EISDIR) try: vfs.remove("no_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) try: vfs.rename("foo_dir", "/null/file") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) try: vfs.rename("foo_dir", "foo_dir/inside_itself") except OSError as e: - print(e.errno == uerrno.EINVAL) + print(e.errno == errno.EINVAL) # file in dir with open("foo_dir/file-in-dir.txt", "w+t") as f: @@ -88,7 +88,7 @@ with open("foo_dir/sub_file.txt", "w") as f: try: vfs.rmdir("foo_dir") except OSError as e: - print(e.errno == uerrno.EACCES) + print(e.errno == errno.EACCES) # trim full path vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt") @@ -117,5 +117,5 @@ try: f = open("large_file.txt", "wb") f.write(bytearray(bsize * free)) except OSError as e: - print("ENOSPC:", e.errno == 28) # uerrno.ENOSPC + print("ENOSPC:", e.errno == 28) # errno.ENOSPC f.close() diff --git a/tests/extmod/vfs_fat_finaliser.py b/tests/extmod/vfs_fat_finaliser.py index 91cce2c95b..37929fd1e3 100644 --- a/tests/extmod/vfs_fat_finaliser.py +++ b/tests/extmod/vfs_fat_finaliser.py @@ -1,9 +1,9 @@ # Test VfsFat class and its finaliser try: - import uerrno, uos + import errno, os - uos.VfsFat + os.VfsFat except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -37,8 +37,8 @@ except MemoryError: raise SystemExit # Format block device and create VFS object -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) # Here we test that opening a file with the heap locked fails correctly. This # is a special case because file objects use a finaliser and allocating with a diff --git a/tests/extmod/vfs_fat_more.py b/tests/extmod/vfs_fat_more.py index f5de729402..9096024c4a 100644 --- a/tests/extmod/vfs_fat_more.py +++ b/tests/extmod/vfs_fat_more.py @@ -1,11 +1,11 @@ try: - import uos + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -46,70 +46,70 @@ except MemoryError: # first we umount any existing mount points the target may have try: - uos.umount("/") + os.umount("/") except OSError: pass -for path in uos.listdir("/"): - uos.umount("/" + path) +for path in os.listdir("/"): + os.umount("/" + path) -uos.VfsFat.mkfs(bdev) -uos.mount(bdev, "/") +os.VfsFat.mkfs(bdev) +os.mount(bdev, "/") -print(uos.getcwd()) +print(os.getcwd()) f = open("test.txt", "w") f.write("hello") f.close() -print(uos.listdir()) -print(uos.listdir("/")) -print(uos.stat("")[:-3]) -print(uos.stat("/")[:-3]) -print(uos.stat("test.txt")[:-3]) -print(uos.stat("/test.txt")[:-3]) +print(os.listdir()) +print(os.listdir("/")) +print(os.stat("")[:-3]) +print(os.stat("/")[:-3]) +print(os.stat("test.txt")[:-3]) +print(os.stat("/test.txt")[:-3]) f = open("/test.txt") print(f.read()) f.close() -uos.rename("test.txt", "test2.txt") -print(uos.listdir()) -uos.rename("test2.txt", "/test3.txt") -print(uos.listdir()) -uos.rename("/test3.txt", "test4.txt") -print(uos.listdir()) -uos.rename("/test4.txt", "/test5.txt") -print(uos.listdir()) +os.rename("test.txt", "test2.txt") +print(os.listdir()) +os.rename("test2.txt", "/test3.txt") +print(os.listdir()) +os.rename("/test3.txt", "test4.txt") +print(os.listdir()) +os.rename("/test4.txt", "/test5.txt") +print(os.listdir()) -uos.mkdir("dir") -print(uos.listdir()) -uos.mkdir("/dir2") -print(uos.listdir()) -uos.mkdir("dir/subdir") -print(uos.listdir("dir")) +os.mkdir("dir") +print(os.listdir()) +os.mkdir("/dir2") +print(os.listdir()) +os.mkdir("dir/subdir") +print(os.listdir("dir")) for exist in ("", "/", "dir", "/dir", "dir/subdir"): try: - uos.mkdir(exist) + os.mkdir(exist) except OSError as er: print("mkdir OSError", er.errno == 17) # EEXIST -uos.chdir("/") -print(uos.stat("test5.txt")[:-3]) +os.chdir("/") +print(os.stat("test5.txt")[:-3]) -uos.VfsFat.mkfs(bdev2) -uos.mount(bdev2, "/sys") -print(uos.listdir()) -print(uos.listdir("sys")) -print(uos.listdir("/sys")) +os.VfsFat.mkfs(bdev2) +os.mount(bdev2, "/sys") +print(os.listdir()) +print(os.listdir("sys")) +print(os.listdir("/sys")) -uos.rmdir("dir2") -uos.remove("test5.txt") -print(uos.listdir()) +os.rmdir("dir2") +os.remove("test5.txt") +print(os.listdir()) -uos.umount("/") -print(uos.getcwd()) -print(uos.listdir()) -print(uos.listdir("sys")) +os.umount("/") +print(os.getcwd()) +print(os.listdir()) +print(os.listdir("sys")) # test importing a file from a mounted FS import sys diff --git a/tests/extmod/vfs_fat_mtime.py b/tests/extmod/vfs_fat_mtime.py index d8fd66b75f..1ceb611364 100644 --- a/tests/extmod/vfs_fat_mtime.py +++ b/tests/extmod/vfs_fat_mtime.py @@ -1,11 +1,11 @@ # Test for VfsFat using a RAM device, mtime feature try: - import utime, uos + import time, os - utime.time - utime.sleep - uos.VfsFat + time.time + time.sleep + os.VfsFat except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -44,11 +44,11 @@ def test(bdev, vfs_class): vfs = vfs_class(bdev) # Create an empty file, should have a timestamp. - current_time = int(utime.time()) + current_time = int(time.time()) vfs.open("test1", "wt").close() # Wait 2 seconds so mtime will increase (FAT has 2 second resolution). - utime.sleep(2) + time.sleep(2) # Create another empty file, should have a timestamp. vfs.open("test2", "wt").close() @@ -71,4 +71,4 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(50) -test(bdev, uos.VfsFat) +test(bdev, os.VfsFat) diff --git a/tests/extmod/vfs_fat_oldproto.py b/tests/extmod/vfs_fat_oldproto.py index 1998319dbe..df8a13c96e 100644 --- a/tests/extmod/vfs_fat_oldproto.py +++ b/tests/extmod/vfs_fat_oldproto.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -43,9 +43,9 @@ except MemoryError: print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +os.VfsFat.mkfs(bdev) +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") # file io with vfs.open("file.txt", "w") as f: diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index a22d480dfd..9a5c49a6cc 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -1,12 +1,12 @@ try: - import uerrno - import uos + import errno + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -44,13 +44,13 @@ except MemoryError: print("SKIP") raise SystemExit -uos.VfsFat.mkfs(bdev) +os.VfsFat.mkfs(bdev) print(b"FOO_FILETXT" not in bdev.data) print(b"hello!" not in bdev.data) -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") vfs.label = "label test" print("label:", vfs.label) @@ -60,7 +60,7 @@ print("getcwd:", vfs.getcwd()) try: vfs.stat("no_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) with vfs.open("foo_file.txt", "w") as f: f.write("hello!") @@ -83,18 +83,18 @@ with vfs.open("sub_file.txt", "w") as f: try: vfs.chdir("sub_file.txt") except OSError as e: - print(e.errno == uerrno.ENOENT) + print(e.errno == errno.ENOENT) vfs.chdir("..") print("getcwd:", vfs.getcwd()) -uos.umount(vfs) +os.umount(vfs) -vfs = uos.VfsFat(bdev) +vfs = os.VfsFat(bdev) print(list(vfs.ilistdir(b""))) # list a non-existent directory try: vfs.ilistdir(b"no_exist") except OSError as e: - print("ENOENT:", e.errno == uerrno.ENOENT) + print("ENOENT:", e.errno == errno.ENOENT) diff --git a/tests/extmod/vfs_fat_ramdisklarge.py b/tests/extmod/vfs_fat_ramdisklarge.py index 649a53db14..40cba9ee43 100644 --- a/tests/extmod/vfs_fat_ramdisklarge.py +++ b/tests/extmod/vfs_fat_ramdisklarge.py @@ -1,13 +1,13 @@ # test making a FAT filesystem on a very large block device try: - import uos + import os except ImportError: print("SKIP") raise SystemExit try: - uos.VfsFat + os.VfsFat except AttributeError: print("SKIP") raise SystemExit @@ -46,13 +46,13 @@ class RAMBDevSparse: try: bdev = RAMBDevSparse(4 * 1024 * 1024 * 1024 // RAMBDevSparse.SEC_SIZE) - uos.VfsFat.mkfs(bdev) + os.VfsFat.mkfs(bdev) except MemoryError: print("SKIP") raise SystemExit -vfs = uos.VfsFat(bdev) -uos.mount(vfs, "/ramdisk") +vfs = os.VfsFat(bdev) +os.mount(vfs, "/ramdisk") print("statvfs:", vfs.statvfs("/ramdisk")) @@ -66,4 +66,4 @@ f = open("/ramdisk/test.txt") print(f.read()) f.close() -uos.umount(vfs) +os.umount(vfs) diff --git a/tests/extmod/vfs_lfs.py b/tests/extmod/vfs_lfs.py index 8e56400df3..f555e00b8c 100644 --- a/tests/extmod/vfs_lfs.py +++ b/tests/extmod/vfs_lfs.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -115,7 +115,7 @@ def test(bdev, vfs_class): vfs.chdir("/testdir") print(vfs.getcwd()) - # create file in directory to make sure paths are relative + # create file in directory to make sre paths are relative vfs.open("test2", "w").close() print_stat(vfs.stat("test2")) print_stat(vfs.stat("/testdir/test2")) @@ -150,5 +150,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_corrupt.py b/tests/extmod/vfs_lfs_corrupt.py index 330458709a..c49dcad92b 100644 --- a/tests/extmod/vfs_lfs_corrupt.py +++ b/tests/extmod/vfs_lfs_corrupt.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, testing error handling from corrupt block device try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -108,5 +108,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_error.py b/tests/extmod/vfs_lfs_error.py index 717284ea01..32b76b2821 100644 --- a/tests/extmod/vfs_lfs_error.py +++ b/tests/extmod/vfs_lfs_error.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, testing error handling try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -117,5 +117,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_file.py b/tests/extmod/vfs_lfs_file.py index 0920173200..574ce1eecb 100644 --- a/tests/extmod/vfs_lfs_file.py +++ b/tests/extmod/vfs_lfs_file.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, file IO try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -117,5 +117,5 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs1) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs1) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_mount.py b/tests/extmod/vfs_lfs_mount.py index c9926708c6..4ebd9ac623 100644 --- a/tests/extmod/vfs_lfs_mount.py +++ b/tests/extmod/vfs_lfs_mount.py @@ -1,10 +1,10 @@ # Test for VfsLittle using a RAM device, with mount/umount try: - import uos + import os - uos.VfsLfs1 - uos.VfsLfs2 + os.VfsLfs1 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -42,7 +42,7 @@ def test(vfs_class): # mount bdev unformatted try: - uos.mount(bdev, "/lfs") + os.mount(bdev, "/lfs") except Exception as er: print(repr(er)) @@ -53,7 +53,7 @@ def test(vfs_class): vfs = vfs_class(bdev) # mount - uos.mount(vfs, "/lfs") + os.mount(vfs, "/lfs") # import with open("/lfs/lfsmod.py", "w") as f: @@ -61,23 +61,23 @@ def test(vfs_class): import lfsmod # import package - uos.mkdir("/lfs/lfspkg") + os.mkdir("/lfs/lfspkg") with open("/lfs/lfspkg/__init__.py", "w") as f: f.write('print("package")\n') import lfspkg # chdir and import module from current directory (needs "" in sys.path) - uos.mkdir("/lfs/subdir") - uos.chdir("/lfs/subdir") - uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py") + os.mkdir("/lfs/subdir") + os.chdir("/lfs/subdir") + os.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py") import lfsmod2 # umount - uos.umount("/lfs") + os.umount("/lfs") # mount read-only vfs = vfs_class(bdev) - uos.mount(vfs, "/lfs", readonly=True) + os.mount(vfs, "/lfs", readonly=True) # test reading works with open("/lfs/subdir/lfsmod2.py") as f: @@ -90,13 +90,13 @@ def test(vfs_class): print(repr(er)) # umount - uos.umount("/lfs") + os.umount("/lfs") # mount bdev again - uos.mount(bdev, "/lfs") + os.mount(bdev, "/lfs") # umount - uos.umount("/lfs") + os.umount("/lfs") # clear imported modules sys.modules.clear() @@ -110,5 +110,5 @@ sys.path.append("/lfs") sys.path.append("") # run tests -test(uos.VfsLfs1) -test(uos.VfsLfs2) +test(os.VfsLfs1) +test(os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_mtime.py b/tests/extmod/vfs_lfs_mtime.py index bacdd2246c..bd8ae7b2a2 100644 --- a/tests/extmod/vfs_lfs_mtime.py +++ b/tests/extmod/vfs_lfs_mtime.py @@ -1,11 +1,11 @@ # Test for VfsLfs using a RAM device, mtime feature try: - import utime, uos + import time, os - utime.time - utime.sleep - uos.VfsLfs2 + time.time + time.sleep + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -47,11 +47,11 @@ def test(bdev, vfs_class): vfs = vfs_class(bdev, mtime=True) # Create an empty file, should have a timestamp. - current_time = int(utime.time()) + current_time = int(time.time()) vfs.open("test1", "wt").close() # Wait 1 second so mtime will increase by at least 1. - utime.sleep(1) + time.sleep(1) # Create another empty file, should have a timestamp. vfs.open("test2", "wt").close() @@ -68,13 +68,13 @@ def test(bdev, vfs_class): print(stat1[8] < stat2[8]) # Wait 1 second so mtime will increase by at least 1. - utime.sleep(1) + time.sleep(1) - # Open test1 for reading and ensure mtime did not change. + # Open test1 for reading and ensre mtime did not change. vfs.open("test1", "rt").close() print(vfs.stat("test1") == stat1) - # Open test1 for writing and ensure mtime increased from the previous value. + # Open test1 for writing and ensre mtime increased from the previous value. vfs.open("test1", "wt").close() stat1_old = stat1 stat1 = vfs.stat("test1") @@ -102,4 +102,4 @@ def test(bdev, vfs_class): bdev = RAMBlockDevice(30) -test(bdev, uos.VfsLfs2) +test(bdev, os.VfsLfs2) diff --git a/tests/extmod/vfs_lfs_superblock.py b/tests/extmod/vfs_lfs_superblock.py index 1ac5675554..b8a8ec60b9 100644 --- a/tests/extmod/vfs_lfs_superblock.py +++ b/tests/extmod/vfs_lfs_superblock.py @@ -1,9 +1,9 @@ # Test for VfsLfs using a RAM device, when the first superblock does not exist try: - import uos + import os - uos.VfsLfs2 + os.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -36,12 +36,12 @@ lfs2_data = b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x bdev = RAMBlockDevice(64, lfs2_data) # Create the VFS explicitly, no auto-detection is needed for this. -vfs = uos.VfsLfs2(bdev) +vfs = os.VfsLfs2(bdev) print(list(vfs.ilistdir())) # Mount the block device directly; this relies on auto-detection. -uos.mount(bdev, "/userfs") -print(uos.listdir("/userfs")) +os.mount(bdev, "/userfs") +print(os.listdir("/userfs")) # Clean up. -uos.umount("/userfs") +os.umount("/userfs") diff --git a/tests/extmod/vfs_posix.py b/tests/extmod/vfs_posix.py index 2a14fc2076..61c948cf5b 100644 --- a/tests/extmod/vfs_posix.py +++ b/tests/extmod/vfs_posix.py @@ -1,9 +1,9 @@ # Test for VfsPosix try: - import uos + import os - uos.VfsPosix + os.VfsPosix except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -12,27 +12,27 @@ except (ImportError, AttributeError): # Skip the test if it does exist. temp_dir = "micropy_test_dir" try: - uos.stat(temp_dir) + os.stat(temp_dir) print("SKIP") raise SystemExit except OSError: pass # getcwd and chdir -curdir = uos.getcwd() -uos.chdir("/") -print(uos.getcwd()) -uos.chdir(curdir) -print(uos.getcwd() == curdir) +curdir = os.getcwd() +os.chdir("/") +print(os.getcwd()) +os.chdir(curdir) +print(os.getcwd() == curdir) # stat -print(type(uos.stat("/"))) +print(type(os.stat("/"))) # listdir and ilistdir -print(type(uos.listdir("/"))) +print(type(os.listdir("/"))) # mkdir -uos.mkdir(temp_dir) +os.mkdir(temp_dir) # file create f = open(temp_dir + "/test", "w") @@ -52,11 +52,11 @@ print(f.read()) f.close() # rename -uos.rename(temp_dir + "/test", temp_dir + "/test2") -print(uos.listdir(temp_dir)) +os.rename(temp_dir + "/test", temp_dir + "/test2") +print(os.listdir(temp_dir)) # construct new VfsPosix with path argument -vfs = uos.VfsPosix(temp_dir) +vfs = os.VfsPosix(temp_dir) print(list(i[0] for i in vfs.ilistdir("."))) # stat, statvfs (statvfs may not exist) @@ -69,21 +69,21 @@ print(type(list(vfs.ilistdir("."))[0][0])) print(type(list(vfs.ilistdir(b"."))[0][0])) # remove -uos.remove(temp_dir + "/test2") -print(uos.listdir(temp_dir)) +os.remove(temp_dir + "/test2") +print(os.listdir(temp_dir)) # remove with error try: - uos.remove(temp_dir + "/test2") + os.remove(temp_dir + "/test2") except OSError: print("remove OSError") # rmdir -uos.rmdir(temp_dir) -print(temp_dir in uos.listdir()) +os.rmdir(temp_dir) +print(temp_dir in os.listdir()) # rmdir with error try: - uos.rmdir(temp_dir) + os.rmdir(temp_dir) except OSError: print("rmdir OSError") diff --git a/tests/extmod/vfs_userfs.py b/tests/extmod/vfs_userfs.py index 3cdfe82eea..518373c70a 100644 --- a/tests/extmod/vfs_userfs.py +++ b/tests/extmod/vfs_userfs.py @@ -1,21 +1,21 @@ # test VFS functionality with a user-defined filesystem -# also tests parts of uio.IOBase implementation +# also tests parts of io.IOBase implementation import sys try: - import uio + import io - uio.IOBase - import uos + io.IOBase + import os - uos.mount + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, mode, data): assert isinstance(data, bytes) self.is_text = mode.find("b") == -1 @@ -69,7 +69,7 @@ user_files = { "/usermod1.py": b"print('in usermod1')\nimport usermod2", "/usermod2.py": b"print('in usermod2')", } -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") # open and read a file f = open("/userfs/data.txt") @@ -80,5 +80,5 @@ sys.path.append("/userfs") import usermod1 # unmount and undo path addition -uos.umount("/userfs") +os.umount("/userfs") sys.path.pop() diff --git a/tests/feature_check/uio_module.py b/tests/feature_check/io_module.py similarity index 56% rename from tests/feature_check/uio_module.py rename to tests/feature_check/io_module.py index bad8d7c95b..9094e60531 100644 --- a/tests/feature_check/uio_module.py +++ b/tests/feature_check/io_module.py @@ -1,6 +1,6 @@ try: - import uio + import io - print("uio") + print("io") except ImportError: print("no") diff --git a/tests/feature_check/uio_module.py.exp b/tests/feature_check/io_module.py.exp similarity index 100% rename from tests/feature_check/uio_module.py.exp rename to tests/feature_check/io_module.py.exp diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py index 1226b39ca9..e2876f5d7c 100644 --- a/tests/float/float2int_doubleprec_intbig.py +++ b/tests/float/float2int_doubleprec_intbig.py @@ -1,9 +1,6 @@ # check cases converting float to int, requiring double precision float -try: - import ustruct as struct -except: - import struct +import struct import sys diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py index a1bfe67046..3d3795f94d 100644 --- a/tests/float/float2int_fp30_intbig.py +++ b/tests/float/float2int_fp30_intbig.py @@ -1,9 +1,6 @@ # check cases converting float to int, relying only on single precision float -try: - import ustruct as struct -except: - import struct +import struct import sys diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py index 06b651bb72..a9d7b57211 100644 --- a/tests/float/float2int_intbig.py +++ b/tests/float/float2int_intbig.py @@ -1,9 +1,6 @@ # check cases converting float to int, relying only on single precision float -try: - import ustruct as struct -except: - import struct +import struct import sys diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index 18893af0e0..47fe405018 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -1,9 +1,6 @@ # test struct package with floats try: - try: - import ustruct as struct - except: - import struct + import struct except ImportError: print("SKIP") raise SystemExit diff --git a/tests/inlineasm/asmsum.py b/tests/inlineasm/asmsum.py index 208709a25f..51613ef6ac 100644 --- a/tests/inlineasm/asmsum.py +++ b/tests/inlineasm/asmsum.py @@ -46,7 +46,7 @@ def asm_sum_bytes(r0, r1): mov(r0, r2) -import uarray as array +import array b = array.array("l", (100, 200, 300, 400)) n = asm_sum_words(len(b), b) diff --git a/tests/io/open_append.py b/tests/io/open_append.py index 49cdd094b3..80a9422d81 100644 --- a/tests/io/open_append.py +++ b/tests/io/open_append.py @@ -1,7 +1,4 @@ -try: - import uos as os -except ImportError: - import os +import os if not hasattr(os, "remove"): print("SKIP") diff --git a/tests/io/open_plus.py b/tests/io/open_plus.py index 3cb2330eed..5199861a4e 100644 --- a/tests/io/open_plus.py +++ b/tests/io/open_plus.py @@ -1,7 +1,4 @@ -try: - import uos as os -except ImportError: - import os +import os if not hasattr(os, "remove"): print("SKIP") diff --git a/tests/micropython/emg_exc.py b/tests/micropython/emg_exc.py index acc39c5dc9..e26fd62e49 100644 --- a/tests/micropython/emg_exc.py +++ b/tests/micropython/emg_exc.py @@ -4,7 +4,7 @@ import micropython import sys try: - import uio + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/micropython/heapalloc_bytesio2.py b/tests/micropython/heapalloc_bytesio2.py index 3b9f141270..05c384a516 100644 --- a/tests/micropython/heapalloc_bytesio2.py +++ b/tests/micropython/heapalloc_bytesio2.py @@ -1,7 +1,7 @@ # Creating BytesIO from immutable object should not immediately # copy its content. try: - import uio + import io import micropython micropython.mem_total @@ -14,7 +14,7 @@ data = b"1234" * 256 before = micropython.mem_total() -buf = uio.BytesIO(data) +buf = io.BytesIO(data) after = micropython.mem_total() diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py index 18f5322ee1..bd1ba4db79 100644 --- a/tests/micropython/heapalloc_iter.py +++ b/tests/micropython/heapalloc_iter.py @@ -5,13 +5,10 @@ except NameError: print("SKIP") raise SystemExit try: - import uarray as array + import array except ImportError: - try: - import array - except ImportError: - print("SKIP") - raise SystemExit + print("SKIP") + raise SystemExit try: from micropython import heap_lock, heap_unlock diff --git a/tests/micropython/import_mpy_invalid.py b/tests/micropython/import_mpy_invalid.py index 894fc582ce..d2f0c9db28 100644 --- a/tests/micropython/import_mpy_invalid.py +++ b/tests/micropython/import_mpy_invalid.py @@ -1,16 +1,16 @@ # test importing of invalid .mpy files try: - import sys, uio, uos + import sys, io, os - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -55,7 +55,7 @@ user_files = { } # create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") sys.path.append("/userfs") # import .mpy files from the user filesystem @@ -67,5 +67,5 @@ for i in range(len(user_files)): print(mod, type(e).__name__, e) # unmount and undo path addition -uos.umount("/userfs") +os.umount("/userfs") sys.path.pop() diff --git a/tests/micropython/import_mpy_native.py b/tests/micropython/import_mpy_native.py index 0dfbca9086..2829de47aa 100644 --- a/tests/micropython/import_mpy_native.py +++ b/tests/micropython/import_mpy_native.py @@ -1,10 +1,10 @@ # test importing of .mpy files with native code (x64 only) try: - import sys, uio, uos + import sys, io, os - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit @@ -15,7 +15,7 @@ if mpy_arch == 0: raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -108,7 +108,7 @@ user_files = { # fmt: on # create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") sys.path.append("/userfs") # import .mpy files from the user filesystem @@ -121,5 +121,5 @@ for i in range(len(user_files)): print(mod, "ValueError", er) # unmount and undo path addition -uos.umount("/userfs") +os.umount("/userfs") sys.path.pop() diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py index 1234184aed..39d7740216 100644 --- a/tests/micropython/import_mpy_native_gc.py +++ b/tests/micropython/import_mpy_native_gc.py @@ -1,17 +1,17 @@ # Test that native code loaded from a .mpy file is retained after a GC. try: - import gc, sys, uio, uos + import gc, sys, io, os sys.implementation._mpy - uio.IOBase - uos.mount + io.IOBase + os.mount except (ImportError, AttributeError): print("SKIP") raise SystemExit -class UserFile(uio.IOBase): +class UserFile(io.IOBase): def __init__(self, data): self.data = memoryview(data) self.pos = 0 @@ -66,7 +66,7 @@ if sys.implementation._mpy not in features0_file_contents: user_files = {"/features0.mpy": features0_file_contents[sys.implementation._mpy]} # Create and mount a user filesystem. -uos.mount(UserFS(user_files), "/userfs") +os.mount(UserFS(user_files), "/userfs") sys.path.append("/userfs") # Import the native function. @@ -87,5 +87,5 @@ for i in range(1000): print(factorial(10)) # Unmount and undo path addition. -uos.umount("/userfs") +os.umount("/userfs") sys.path.pop() diff --git a/tests/micropython/opt_level.py b/tests/micropython/opt_level.py index dd5493a7a3..8ba7b3a228 100644 --- a/tests/micropython/opt_level.py +++ b/tests/micropython/opt_level.py @@ -1,4 +1,4 @@ -import micropython as micropython +import micropython # check we can get and set the level micropython.opt_level(0) diff --git a/tests/perf_bench/bm_hexiom.py b/tests/perf_bench/bm_hexiom.py index 84eda9a909..e36fc234cd 100644 --- a/tests/perf_bench/bm_hexiom.py +++ b/tests/perf_bench/bm_hexiom.py @@ -632,10 +632,7 @@ bm_params = { def bm_setup(params): - try: - import uio as io - except ImportError: - import io + import io loops, level, order, strategy = params diff --git a/tests/perf_bench/core_import_mpy_multi.py b/tests/perf_bench/core_import_mpy_multi.py index 682c36328a..4e098eef81 100644 --- a/tests/perf_bench/core_import_mpy_multi.py +++ b/tests/perf_bench/core_import_mpy_multi.py @@ -1,8 +1,8 @@ # Test performance of importing an .mpy file many times. -import usys, uio, uos +import usys, io, os -if not (hasattr(uio, "IOBase") and hasattr(uos, "mount")): +if not (hasattr(io, "IOBase") and hasattr(os, "mount")): print("SKIP") raise SystemExit @@ -26,7 +26,7 @@ result = 123 file_data = b'M\x06\x00\x1f\x14\x03\x0etest.py\x00\x0f\x02A\x00\x02f\x00\x0cresult\x00/-5#\x82I\x81{\x81w\x82/\x81\x05\x81\x17Iom\x82\x13\x06arg\x00\x05\x1cthis will be a string object\x00\x06\x1bthis will be a bytes object\x00\n\x07\x05\x0bconst tuple\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x81\\\x10\n\x01\x89\x07d`T2\x00\x10\x024\x02\x16\x022\x01\x16\x03"\x80{\x16\x04Qc\x02\x81d\x00\x08\x02(DD\x11\x05\x16\x06\x10\x02\x16\x072\x00\x16\x082\x01\x16\t2\x02\x16\nQc\x03`\x1a\x08\x08\x12\x13@\xb1\xb0\x18\x13Qc@\t\x08\t\x12` Qc@\t\x08\n\x12``Qc\x82@ \x0e\x03\x80\x08+)##\x12\x0b\x12\x0c\x12\r\x12\x0e*\x04Y\x12\x0f\x12\x10\x12\x11*\x03Y#\x00\xc0#\x01\xc0#\x02\xc0Qc' -class File(uio.IOBase): +class File(io.IOBase): def __init__(self): self.off = 0 @@ -57,8 +57,8 @@ class FS: def mount(): - uos.mount(FS(), "/__remote") - uos.chdir("/__remote") + os.mount(FS(), "/__remote") + os.chdir("/__remote") def test(r): diff --git a/tests/perf_bench/core_import_mpy_single.py b/tests/perf_bench/core_import_mpy_single.py index af3f4a29b2..1b411fc3fb 100644 --- a/tests/perf_bench/core_import_mpy_single.py +++ b/tests/perf_bench/core_import_mpy_single.py @@ -2,9 +2,9 @@ # The first import of a module will intern strings that don't already exist, and # this test should be representative of what happens in a real application. -import uio, uos +import io, os -if not (hasattr(uio, "IOBase") and hasattr(uos, "mount")): +if not (hasattr(io, "IOBase") and hasattr(os, "mount")): print("SKIP") raise SystemExit @@ -81,7 +81,7 @@ result = 123 file_data = b"M\x06\x00\x1f\x81=\x1e\x0etest.py\x00\x0f\x04A0\x00\x04A1\x00\x04f0\x00\x04f1\x00\x0cresult\x00/-5\x04a0\x00\x04a1\x00\x04a2\x00\x04a3\x00\x13\x15\x17\x19\x1b\x1d\x1f!#%')+1379;=?ACEGIKMOQSUWY[]_acegikmoqsuwy{}\x7f\x81\x01\x81\x03\x81\x05\x81\x07\x81\t\x81\x0b\x81\r\x81\x0f\x81\x11\x81\x13\x81\x15\x81\x17\x81\x19\x81\x1b\x81\x1d\x81\x1f\x81!\x81#\x81%\x81'\x81)\x81+\x81-\x81/\x811\x813\x815\x817\x819\x81;\x81=\x81?\x81A\x81C\x81E\x81G\x81I\x81K\x81M\x81O\x81Q\x81S\x81U\x81W\x81Y\x81[\x81]\x81_\x81a\x81c\x81e\x81g\x81i\x81k\x81m\x81o\x81q\x81s\x81u\x81w\x81y\x81{\x81}\x81\x7f\x82\x01\x82\x03\x82\x05\x82\x07\x82\t\x82\x0b\x82\r\x82\x0f\x82\x11\x82\x13\x82\x15\x82\x17\x82\x19\x82\x1b\x82\x1d\x82\x1f\x82!\x82#\x82%\x82'\x82)\x82+\x82-\x82/\x821\x823\x825\x827\x829\x82;\x82=\x82?\x82A\x82E\x82G\x82I\x82K\nname0\x00\nname1\x00\nname2\x00\nname3\x00\nname4\x00\nname5\x00\nname6\x00\nname7\x00\nname8\x00\nname9\x00$quite_a_long_name0\x00$quite_a_long_name1\x00$quite_a_long_name2\x00$quite_a_long_name3\x00$quite_a_long_name4\x00$quite_a_long_name5\x00$quite_a_long_name6\x00$quite_a_long_name7\x00$quite_a_long_name8\x00$quite_a_long_name9\x00&quite_a_long_name10\x00&quite_a_long_name11\x00\x05\x1ethis will be a string object 0\x00\x05\x1ethis will be a string object 1\x00\x05\x1ethis will be a string object 2\x00\x05\x1ethis will be a string object 3\x00\x05\x1ethis will be a string object 4\x00\x05\x1ethis will be a string object 5\x00\x05\x1ethis will be a string object 6\x00\x05\x1ethis will be a string object 7\x00\x05\x1ethis will be a string object 8\x00\x05\x1ethis will be a string object 9\x00\x06\x1dthis will be a bytes object 0\x00\x06\x1dthis will be a bytes object 1\x00\x06\x1dthis will be a bytes object 2\x00\x06\x1dthis will be a bytes object 3\x00\x06\x1dthis will be a bytes object 4\x00\x06\x1dthis will be a bytes object 5\x00\x06\x1dthis will be a bytes object 6\x00\x06\x1dthis will be a bytes object 7\x00\x06\x1dthis will be a bytes object 8\x00\x06\x1dthis will be a bytes object 9\x00\n\x07\x05\rconst tuple 0\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 1\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 2\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 3\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 4\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 5\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 6\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 7\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 8\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\n\x07\x05\rconst tuple 9\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x82d\x10\x12\x01i@i@\x84\x18\x84\x1fT2\x00\x10\x024\x02\x16\x02T2\x01\x10\x034\x02\x16\x032\x02\x16\x042\x03\x16\x05\"\x80{\x16\x06Qc\x04\x82\x0c\x00\n\x02($$$\x11\x07\x16\x08\x10\x02\x16\t2\x00\x16\n2\x01\x16\x0b2\x02\x16\x0c2\x03\x16\rQc\x04@\t\x08\n\x81\x0b Qc@\t\x08\x0b\x81\x0b@Qc@\t\x08\x0c\x81\x0b`QcH\t\n\r\x81\x0b` Qc\x82\x14\x00\x0c\x03h`$$$\x11\x07\x16\x08\x10\x03\x16\t2\x00\x16\n2\x01\x16\x0b2\x02\x16\x0c2\x03\x16\rQc\x04H\t\n\n\x81\x0b``QcH\t\n\x0b\x81\x0b\x80\x07QcH\t\n\x0c\x81\x0b\x80\x08QcH\t\n\r\x81\x0b\x80\tQc\xa08P:\x04\x80\x0b13///---997799<\x1f%\x1f\"\x1f%)\x1f\"//\x12\x0e\x12\x0f\x12\x10\x12\x11\x12\x12\x12\x13\x12\x14*\x07Y\x12\x15\x12\x16\x12\x17\x12\x18\x12\x19\x12\x1a\x12\x08\x12\x07*\x08Y\x12\x1b\x12\x1c\x12\t\x12\x1d\x12\x1e\x12\x1f*\x06Y\x12 \x12!\x12\"\x12#\x12$\x12%*\x06Y\x12&\x12'\x12(\x12)\x12*\x12+*\x06Y\x12,\x12-\x12.\x12/\x120*\x05Y\x121\x122\x123\x124\x125*\x05Y\x126\x127\x128\x129\x12:*\x05Y\x12;\x12<\x12=\x12>\x12?\x12@\x12A\x12B\x12C\x12D\x12E*\x0bY\x12F\x12G\x12H\x12I\x12J\x12K\x12L\x12M\x12N\x12O\x12P*\x0bY\x12Q\x12R\x12S\x12T\x12U\x12V\x12W\x12X\x12Y\x12Z*\nY\x12[\x12\\\x12]\x12^\x12_\x12`\x12a\x12b\x12c\x12d*\nY\x12e\x12f\x12g\x12h\x12i\x12j\x12k\x12l\x12m\x12n\x12o*\x0bY\x12p\x12q\x12r\x12s\x12t\x12u\x12v\x12w\x12x\x12y\x12z*\x0bY\x12{\x12|\x12}\x12~\x12\x7f\x12\x81\x00\x12\x81\x01\x12\x81\x02\x12\x81\x03\x12\x81\x04*\nY\x12\x81\x05\x12\x81\x06\x12\x81\x07\x12\x81\x08\x12\x81\t\x12\x81\n\x12\x81\x0b\x12\x81\x0c\x12\x81\r\x12\x81\x0e\x12\x81\x0f*\x0bY\x12\x81\x10\x12\x81\x11\x12\x81\x12\x12\x81\x13\x12\x81\x14\x12\x81\x15\x12\x81\x16\x12\x81\x17\x12\x81\x18\x12\x81\x19*\nY\x12\x81\x1a\x12\x81\x1b\x12\x81\x1c\x12\x81\x1d\x12\x81\x1e\x12\x81\x1f\x12\x81 \x12\x81!\x12\x81\"\x12\x81#\x12\x81$*\x0bY\x12\x81%\x12\x81&*\x02Y\x12\x81'\x12\x81(\x12\x81)\x12\x81*\x12\x81+\x12\x81,\x12\x81-\x12\x81.\x12\x81/\x12\x810*\nY\x12\x811\x12\x812\x12\x813\x12\x814*\x04Y\x12\x815\x12\x816\x12\x817\x12\x818*\x04Y\x12\x819\x12\x81:\x12\x81;\x12\x81<*\x04YQc\x87p\x08@\x05\x80###############################\x00\xc0#\x01\xc0#\x02\xc0#\x03\xc0#\x04\xc0#\x05\xc0#\x06\xc0#\x07\xc0#\x08\xc0#\t\xc0#\n\xc0#\x0b\xc0#\x0c\xc0#\r\xc0#\x0e\xc0#\x0f\xc0#\x10\xc0#\x11\xc0#\x12\xc0#\x13\xc0#\x14\xc0#\x15\xc0#\x16\xc0#\x17\xc0#\x18\xc0#\x19\xc0#\x1a\xc0#\x1b\xc0#\x1c\xc0#\x1d\xc0Qc" -class File(uio.IOBase): +class File(io.IOBase): def __init__(self): self.off = 0 @@ -112,8 +112,8 @@ class FS: def mount(): - uos.mount(FS(), "/__remote") - uos.chdir("/__remote") + os.mount(FS(), "/__remote") + os.chdir("/__remote") def test(): diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index a957fbb6b6..2a0997c185 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -22,13 +22,13 @@ TEST_MAPPINGS = { "uheapq": "uheapq/uheapq_$(ARCH).mpy", "urandom": "urandom/urandom_$(ARCH).mpy", "ure": "ure/ure_$(ARCH).mpy", - "uzlib": "uzlib/uzlib_$(ARCH).mpy", + "zlib": "zlib/zlib_$(ARCH).mpy", } # Code to allow a target MicroPython to import an .mpy from RAM injected_import_hook_code = """\ -import sys, uos, uio -class __File(uio.IOBase): +import sys, os, io +class __File(io.IOBase): def __init__(self): self.off = 0 def ioctl(self, request, arg): @@ -49,8 +49,8 @@ class __FS: raise OSError(-2) # ENOENT def open(self, path, mode): return __File() -uos.mount(__FS(), '/__remote') -uos.chdir('/__remote') +os.mount(__FS(), '/__remote') +os.chdir('/__remote') sys.modules['{}'] = __import__('__injected') """ diff --git a/tests/run-tests-exp.py b/tests/run-tests-exp.py index bf8ce32ea8..bbb057f4ce 100644 --- a/tests/run-tests-exp.py +++ b/tests/run-tests-exp.py @@ -6,7 +6,7 @@ # which is to be tested, so should use minimal language functionality. # import sys -import uos as os +import os tests = ["basics", "micropython", "float", "import", "io", " misc", "unicode", "extmod", "unix"] diff --git a/tests/run-tests.py b/tests/run-tests.py index 45b4ebf536..9f55f0ebab 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -355,9 +355,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): if output == b"TypeError\n": skip_revops = True - # Check if uio module exists, and skip such tests if it doesn't - output = run_feature_check(pyb, args, base_path, "uio_module.py") - if output != b"uio\n": + # Check if io module exists, and skip such tests if it doesn't + output = run_feature_check(pyb, args, base_path, "io_module.py") + if output != b"io\n": skip_io_module = True # Check if fstring feature is enabled, and skip such tests if it doesn't diff --git a/tests/stress/recursive_data.py b/tests/stress/recursive_data.py index 3b7fa50952..6e01319ed3 100644 --- a/tests/stress/recursive_data.py +++ b/tests/stress/recursive_data.py @@ -1,6 +1,6 @@ # This tests that printing recursive data structure doesn't lead to segfault. try: - import uio as io + import io except ImportError: print("SKIP") raise SystemExit diff --git a/tests/thread/stress_aes.py b/tests/thread/stress_aes.py index 0ff5544aa8..319087c487 100644 --- a/tests/thread/stress_aes.py +++ b/tests/thread/stress_aes.py @@ -218,10 +218,7 @@ class AES: ################################################################## # test code -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/stress_heap.py b/tests/thread/stress_heap.py index 41dfa5f376..9487b310ac 100644 --- a/tests/thread/stress_heap.py +++ b/tests/thread/stress_heap.py @@ -5,10 +5,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_exit1.py b/tests/thread/thread_exit1.py index a6b00ca1f7..8e405c0d0f 100644 --- a/tests/thread/thread_exit1.py +++ b/tests/thread/thread_exit1.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_exit2.py b/tests/thread/thread_exit2.py index 2381fa5ebc..842eabf895 100644 --- a/tests/thread/thread_exit2.py +++ b/tests/thread/thread_exit2.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_lock2.py b/tests/thread/thread_lock2.py index c43b4b18d1..b476de2f7c 100644 --- a/tests/thread/thread_lock2.py +++ b/tests/thread/thread_lock2.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread lock = _thread.allocate_lock() diff --git a/tests/thread/thread_lock4.py b/tests/thread/thread_lock4.py index 7637d10b96..faa1fd724a 100644 --- a/tests/thread/thread_lock4.py +++ b/tests/thread/thread_lock4.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_qstr1.py b/tests/thread/thread_qstr1.py index 9e7d7f0326..97783bd090 100644 --- a/tests/thread/thread_qstr1.py +++ b/tests/thread/thread_qstr1.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_start1.py b/tests/thread/thread_start1.py index 6f08a135e4..673e46261b 100644 --- a/tests/thread/thread_start1.py +++ b/tests/thread/thread_start1.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/thread/thread_start2.py b/tests/thread/thread_start2.py index 40f8a05227..114a1025e2 100644 --- a/tests/thread/thread_start2.py +++ b/tests/thread/thread_start2.py @@ -4,10 +4,7 @@ # # SPDX-License-Identifier: MIT -try: - import utime as time -except ImportError: - import time +import time import _thread diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py index bb22485026..32b8d90892 100644 --- a/tests/unix/extra_coverage.py +++ b/tests/unix/extra_coverage.py @@ -4,8 +4,8 @@ except NameError: print("SKIP") raise SystemExit -import uerrno -import uio +import errno +import io data = extra_coverage() @@ -18,7 +18,7 @@ print(hash(str(data[1], "utf8"))) # test streams stream = data[2] # has set_error and set_buf. Write always returns error -stream.set_error(uerrno.EAGAIN) # non-blocking error +stream.set_error(errno.EAGAIN) # non-blocking error print(stream.read()) # read all encounters non-blocking error print(stream.read(1)) # read 1 byte encounters non-blocking error print(stream.readline()) # readline encounters non-blocking error @@ -42,8 +42,8 @@ stream2 = data[3] # is textio print(stream2.read(1)) # read 1 byte encounters non-blocking error with textio stream # test BufferedWriter with stream errors -stream.set_error(uerrno.EAGAIN) -buf = uio.BufferedWriter(stream, 8) +stream.set_error(errno.EAGAIN) +buf = io.BufferedWriter(stream, 8) print(buf.write(bytearray(16))) # function defined in C++ code diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index b9742461e4..f91b64db3e 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -46,25 +46,25 @@ RuntimeError: RuntimeError: # repl ame__ -mport +port -builtins micropython __future__ _thread -_uasyncio aesio array audiocore -audiomixer bitmaptools cexample cmath -collections cppexample displayio gc -math qrio rainbowio struct -synthio termios traceback ubinascii -uctypes uerrno uhashlib uheapq -uio ujson ulab ulab.numpy -ulab.numpy.fft ulab.numpy.linalg ulab.scipy +builtins micropython __future__ _asyncio +_thread aesio array audiocore +audiomixer binascii bitmaptools cexample +cmath collections cppexample displayio +errno gc hashlib heapq +io json math os +qrio rainbowio random re +select struct synthio sys +termios time traceback uctypes +ulab ulab.numpy ulab.numpy.fft +ulab.numpy.linalg ulab.scipy ulab.scipy.linalg ulab.scipy.optimize ulab.scipy.signal ulab.scipy.special -ulab.utils uos urandom ure -uselect usys utime utimeq -uzlib zlib -ime +ulab.utils zlib +me -utime utimeq +rainbowio random argv atexit byteorder exc_info exit getsizeof implementation maxsize diff --git a/tests/unix/time.py b/tests/unix/time.py index 55a4b18aae..d1c03c103d 100644 --- a/tests/unix/time.py +++ b/tests/unix/time.py @@ -1,7 +1,4 @@ -try: - import utime as time -except ImportError: - import time +import time DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]