circuitpython/tests/micropython/heapalloc_exc_compressed_emg_exc.py
Damien George 3440201e2e 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>
2022-03-07 16:48:35 +11:00

40 lines
744 B
Python

import micropython
# Does the full test from heapalloc_exc_compressed.py but while the heap is
# locked (this can only work when the emergency exception buf is enabled).
# Some ports need to allocate heap for the emgergency exception buffer.
try:
micropython.alloc_emergency_exception_buf(256)
except AttributeError:
pass
def test():
micropython.heap_lock()
try:
name()
except NameError as e:
print(type(e).__name__, e)
try:
raise 0
except TypeError as e:
print(type(e).__name__, e)
try:
name()
except NameError as e:
print(e.args[0])
try:
raise 0
except TypeError as e:
print(e.args[0])
micropython.heap_unlock()
test()