diff options
author | Damien George <damien@micropython.org> | 2022-03-07 16:47:33 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-03-07 16:48:35 +1100 |
commit | 3440201e2e6861be77aecb1d5069a6cfe4ccc328 (patch) | |
tree | 57162169aa0410e1b6e45d056fd4aea8c8fe7702 /tests/micropython/heapalloc_exc_compressed.py | |
parent | 9a8ee6a5df8d59d0c88a14d81fe40ad95a31c1e4 (diff) |
tests/micropython: Switch from set.pop to raise-0 to test exc strings.
To not rely on sets, which are an optional feature.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython/heapalloc_exc_compressed.py')
-rw-r--r-- | tests/micropython/heapalloc_exc_compressed.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/micropython/heapalloc_exc_compressed.py b/tests/micropython/heapalloc_exc_compressed.py index 79e423ca0..aa071d641 100644 --- a/tests/micropython/heapalloc_exc_compressed.py +++ b/tests/micropython/heapalloc_exc_compressed.py @@ -5,12 +5,10 @@ import micropython # mp_obj_new_exception_msg (decompression can be deferred) # NameError uses mp_obj_new_exception_msg_varg for NameError("name '%q' isn't defined") -# set.pop uses mp_obj_new_exception_msg for KeyError("pop from an empty set") +# `raise 0` uses mp_obj_new_exception_msg for TypeError("exceptions must derive from BaseException") # Tests that deferred decompression works both via print(e) and accessing the message directly via e.args. -a = set() - # First test the regular case (can use heap for allocating the decompression buffer). try: name() @@ -18,8 +16,8 @@ except NameError as e: print(type(e).__name__, e) try: - a.pop() -except KeyError as e: + raise 0 +except TypeError as e: print(type(e).__name__, e) try: @@ -28,8 +26,8 @@ except NameError as e: print(e.args[0]) try: - a.pop() -except KeyError as e: + raise 0 +except TypeError as e: print(e.args[0]) # Then test that it still works when the heap is locked (i.e. in ISR context). @@ -41,8 +39,8 @@ except NameError as e: print(type(e).__name__) try: - a.pop() -except KeyError as e: + raise 0 +except TypeError as e: print(type(e).__name__) micropython.heap_unlock() |