aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2020-06-16py/compile: Implement PEP 572, assignment expressions with := operator.Damien George
The syntax matches CPython and the semantics are equivalent except that, unlike CPython, MicroPython allows using := to assign to comprehension iteration variables, because disallowing this would take a lot of code to check for it. The new compile-time option MICROPY_PY_ASSIGN_EXPR selects this feature and is enabled by default, following MICROPY_PY_ASYNC_AWAIT.
2020-06-10tests/run-multitests.py: Allow passing unique env vars to each instance.Jim Mussared
For example, to run the BLE multitests entirely with the unix port: env MICROPY_MICROPYTHON=../ports/unix/micropython-dev ./run-multitests.py \ -i micropython,MICROPYBTUSB=01 \ -i micropython,MICROPYBTUSB=02:02 \ multi_bluetooth/ble_*.py
2020-06-10extmod/uasyncio: Add asyncio.wait_for_ms function.Damien George
Fixes issue #6107.
2020-06-10py/objtype: Add __dict__ attribute for class objects.Andrew Leech
The behavior mirrors the instance object dict attribute where a copy of the local attributes are provided (unless the dict is read-only, then that dict itself is returned, as an optimisation). MicroPython does not support modifying this dict because the changes will not be reflected in the class. The feature is only enabled if MICROPY_CPYTHON_COMPAT is set, the same as the instance version.
2020-06-08extmod/ure: Use single function for match/search/sub.stijn
Saves about 500 bytes on unix x64 and enables CPython-conform usage of passing a re object to these functions.
2020-06-05tests/multi_bluetooth: Update to work with new BLE events.Jim Mussared
Updates the tests to use non-bitmask events, event renames, as well as some of the new completion events to improve reliability of the tests.
2020-06-02py/modbuiltins: Fix getattr to work with class raising AttributeError.Damien George
Fixes issue #6089.
2020-05-29extmod/vfs: Retain previous working directory if chdir fails.Damien George
Fixes issue #6069.
2020-05-28py/modmath: Work around msvc float bugs in atan2, fmod and modf.stijn
Older implementations deal with infinity/negative zero incorrectly. This commit adds generic fixes that can be enabled by any port that needs them, along with new tests cases.
2020-05-15extmod/vfs_lfsx: Fix import_stat so it takes into account current dir.Damien George
CPython semantics require searching the current directory if the import is not absolute (when "" is in sys.path). Fixes issue #6037.
2020-05-11extmod/modbluetooth: Add support for changing the GAP device name.Damien George
This commit allows the user to set/get the GAP device name used by service 0x1800, characteristic 0x2a00. The usage is: BLE.config(gap_name="myname") print(BLE.config("gap_name")) As part of this change the compile-time setting MICROPY_PY_BLUETOOTH_DEFAULT_NAME is renamed to MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME to emphasise its link to GAP and this new "gap_name" config value. And the default value of this for the NimBLE bindings is changed from "PYBD" to "MPY NIMBLE" to be more generic.
2020-05-09esp32/modsocket: Fix getaddrinfo to raise on error.Thorsten von Eicken
This commit fixes the behaviour of socket.getaddrinfo on the ESP32 so it raises an OSError when the name resolution fails instead of returning a [] or a resolution for 0.0.0.0. Tests are added (generic and ESP32-specific) to verify behaviour consistent with CPython, modulo the different types of exceptions per MicroPython documentation.
2020-05-09tests/run-tests: Skip REPL feature checks when running via pyboard.py.Damien George
2020-05-09tests/run-multitests.py: Add TRACE banner and move TEST output to end.Damien George
To make it easier to understand the output when both -s and -t are used.
2020-05-08extmod/vfs_lfsx: Fix rename to respect cur dir for new path.robert
If the new name start with '/', cur_dir is not prepened any more, so that the current working directory is respected. And extend the test cases for rename to cover this functionality.
2020-05-08extmod/vfs_lfsx: Normalize path name in chdir.robert
This change scans for '.', '..' and multiple '/' and normalizes the new path name. If the resulting path does not exist, an error is raised. Non-existing interim path elements are ignored if they are removed during normalization.
2020-05-08extmod/vfs_lfsx: Fix path handling in uos.stat() to consider cur dir.robert
This fixes the bug, that stat(filename) would not consider the current working directory. So if e.g. the cwd is "lib", then stat("main.py") would return the info for "/main.py" instead of "/lib/main.py".
2020-05-08tests/multi_bluetooth: Fix typo printing wrong IRQ type.Damien George
2020-05-05tests/thread/thread_stacksize1.py: Increase stack size for CPython.yangfl
On arm64 with CPython: >>> _thread.stack_size(32*1024) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: size not valid: 32768 bytes So increase the CPython value in the test to 512k so it runs on more systems (on modern Linux the default stack size is usually 8MB).
2020-05-03py/parse: Support constant folding of power operator for integers.Damien George
Constant expression like "2 ** 3" will now be folded, and the special form "X = const(2 ** 3)" will now compile because the argument to the const is now a constant. Fixes issue #5865.
2020-05-03esp32: Improve support for OTA updates.Thorsten von Eicken
This commit adds several small items to improve the support for OTA updates on an esp32: - a partition table for 4MB flash modules that has two OTA partitions ready to go to do updates - a GENERIC_OTA board that uses that partition table and that enables automatic roll-back in the bootloader - a new esp32.Partition.mark_app_valid_cancel_rollback() class-method to signal that the boot is successful and should not be rolled back at the next reset - an automated test for doing an OTA update - documentation updates
2020-05-02tests/cpydiff: Add cpydiff test for __all__ used in imported package.Jim Mussared
2020-05-02extmod/modbtree: Retain reference to underlying stream so it's not GC'd.Damien George
For ports that have a system malloc which is not garbage collected (eg unix, esp32), the stream object for the DB must be retained separately to prevent it from being reclaimed by the MicroPython GC (because the berkeley-db library uses malloc to allocate the DB structure which stores the only reference to the stream). Although in some cases the user code will explicitly retain a reference to the underlying stream because it needs to call close() on it, this is not always the case, eg in cases where the DB is intended to live forever. Fixes issue #5940.
2020-04-29tests/run-multitests.py: Add shortcuts for local Python instances.Jim Mussared
One can now use `-i micropython` and `-i cpython` to add instances using the `MICROPYTHON` and `CPYTHON3` variables (which can be overridden by env vars).
2020-04-29tests/multi_bluetooth/ble_gap_advertise: Fix bytes/str compare warning.Jim Mussared
2020-04-29tests/run-multitests.py: Allow filtering out lines from stdout.Jim Mussared
And use this new feature to filter out certain lines in the Bluetooth multitests.
2020-04-27tests/extmod: Add btree test for errors raised by btree DB library.Damien George
This test now passes given the previous two commits.
2020-04-27py/objdict: Fix popitem for ordered dicts.Jim Mussared
The popitem method wasn't implemented for ordered dicts and would result in an invalid state. Fixes issue #5956.
2020-04-23esp32: Consolidate check_esp_err functions and add IDF error string.Thorsten von Eicken
This commit consolidates a number of check_esp_err functions that check whether an ESP-IDF return code is OK and raises an exception if not. The exception raised is an OSError with the error code as the first argument (negative if it's ESP-IDF specific) and the ESP-IDF error string as the second argument. This commit also fixes esp32.Partition.set_boot to use check_esp_err, and uses that function for a unit test.
2020-04-23esp32/modesp32: Add idf_heap_info(capabilities) to esp32 module.Thorsten von Eicken
This commit adds an idf_heap_info(capabilities) method to the esp32 module which returns info about the ESP-IDF heaps. It's useful to get a bit of a picture of what's going on when code fails because ESP-IDF can't allocate memory anymore. Includes documentation and a test.
2020-04-18py/objint: Do not use fpclassify.stijn
For combinations of certain versions of glibc and gcc the definition of fpclassify always takes float as argument instead of adapting itself to float/double/long double as required by the C99 standard. At the time of writing this happens for instance for glibc 2.27 with gcc 7.5.0 when compiled with -Os and glibc 3.0.7 with gcc 9.3.0. When calling fpclassify with double as argument, as in objint.c, this results in an implicit narrowing conversion which is not really correct plus results in a warning when compiled with -Wfloat-conversion. So fix this by spelling out the logic manually.
2020-04-18tests/float: Fix cmath_fun_special for MICROPY_FLOAT_IMPL_FLOAT.stijn
When the unix and windows ports use MICROPY_FLOAT_IMPL_FLOAT instead of MICROPY_FLOAT_IMPL_DOUBLE, the test output has for example complex(-0.15052, 0.34109) instead of the expected complex(-0.15051, 0.34109). Use one decimal place less for the output printing to fix this.
2020-04-14extmod/uasyncio: Change cannot to can't in error message, and test exp.Damien George
Follow up to 8e048d2548867aac743866ca5a4c244b7b5aac09 which missed these.
2020-04-13extmod/uasyncio: Add Loop.new_event_loop method.Damien George
This commit adds Loop.new_event_loop() which is used to reset the singleton event loop. This functionality is put here instead of in Loop.close() to make it possible to write code that is compatible with CPython.
2020-04-13py/scheduler: Add assert that scheduler is locked when unlocking.Jim Mussared
And add a test that shows how this can happen when multiple threads are accessing the scheduler, which fails if atomic sections are not used.
2020-04-13tests/run-tests: Make diff tool user configurable.stijn
2020-04-09py/parse: Remove unnecessary check in const folding for ** operator.Damien George
In this part of the code there is no way to get the ** operator, so no need to check for it. This commit also adds tests for this, and other related, invalid const operations.
2020-04-09tests/extmod: Update littlefs test output to match new library version.Damien George
The amount of free space on the VfsLfs2 filesystem after creating a large file is reduced by 2 blocks in this test.
2020-04-07extmod/modbluetooth: Provide FLAG_WRITE_NO_RESPONSE for characteristics.Damien George
This flag is supported and needs to be set if characteristics are write- without-response.
2020-04-05py/objexcept: Allow compression of exception message text.Jim Mussared
The decompression of error-strings is only done if the string is accessed via printing or via er.args. Tests are added for this feature to ensure the decompression works.
2020-04-04docs,tests: Add docs and test for uasyncio custom exc handler methods.Damien George
2020-04-02extmod/uasyncio: Implement Loop.stop() to stop the event loop.Damien George
2020-03-30tests/run-tests: Add commands to print and clean *.exp,out files.David Lechner
This adds a couple of commands to the run-tests script to print the diffs of failed tests and also to clean up the .exp and .out files after failed tests. (And a spelling error is fixed while we are touching nearby code.) Travis is also updated to use these new commands, including using it for more builds.
2020-03-30tests/float: Add new lexer test to test parsing of float without prefix.David Lechner
Since automatically formatting tests with black, we have lost one line of code coverage. This adds an explicit test to ensure we are testing the case that is no longer covered implicitly.
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
2020-03-30tests/micropython/heapalloc_fail_set.py: Remove extra trailing comma.David Lechner
Unlike tuples, sets do not need trailing comma when there is only one item.
2020-03-28tests/basics/dict_pop.py: Remove extra comma in call and fix grammar.David Lechner
2020-03-26tests/net_inet: Add uasyncio internet tests.Damien George
2020-03-26tests/multi_net: Add uasyncio test for TCP server and client.Damien George
Includes a test where the (non uasyncio) client does a RST on the connection, as a simple TCP server/client test where both sides are using uasyncio, and a test for TCP stream close then write.
2020-03-26tests: Make default MICROPYPATH include extmod to find uasyncio.Damien George