diff options
| author | Damien George | 2019-04-18 14:34:12 +1000 |
|---|---|---|
| committer | Damien George | 2019-04-18 14:34:12 +1000 |
| commit | eb1f81b209f0d13059ebb4fa2ed105a0d6a4b0d0 (patch) | |
| tree | be61d020fc09161fc856d3f1516495219b647978 /tests/micropython/heapalloc_fail_dict.py | |
| parent | 4ce0091449052daca592f852a31eece074d34a57 (diff) | |
tests/micropython: Add some tests for failed heap allocation.
This adds tests for some locations in the code where a memory allocation
should raise an exception.
Diffstat (limited to 'tests/micropython/heapalloc_fail_dict.py')
| -rw-r--r-- | tests/micropython/heapalloc_fail_dict.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/micropython/heapalloc_fail_dict.py b/tests/micropython/heapalloc_fail_dict.py new file mode 100644 index 000000000..ba872bfeb --- /dev/null +++ b/tests/micropython/heapalloc_fail_dict.py @@ -0,0 +1,21 @@ +# test handling of failed heap allocation with dict + +import micropython + +# create dict +x = 1 +micropython.heap_lock() +try: + {x:x} +except MemoryError: + print('MemoryError: create dict') +micropython.heap_unlock() + +# create dict view +x = {1:1} +micropython.heap_lock() +try: + x.items() +except MemoryError: + print('MemoryError: dict.items') +micropython.heap_unlock() |
