circuitpython/tests/micropython/heap_lock.py
Damien George c607b58efe tests: Move heap-realloc-while-locked test from C to Python.
This test for calling gc_realloc() while the GC is locked can be done in
pure Python, so better to do it that way since it can then be tested on
more ports.
2018-03-02 10:59:09 +11:00

26 lines
405 B
Python

# check that heap_lock/heap_unlock work as expected
import micropython
l = []
l2 = list(range(100))
micropython.heap_lock()
# general allocation on the heap
try:
print([])
except MemoryError:
print('MemoryError')
# expansion of a heap block
try:
l.extend(l2)
except MemoryError:
print('MemoryError')
micropython.heap_unlock()
# check that allocation works after an unlock
print([])