3dc324d3f1
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.
35 lines
548 B
Python
35 lines
548 B
Python
# check that heap_lock/heap_unlock work as expected
|
|
|
|
import micropython
|
|
|
|
l = []
|
|
l2 = list(range(100))
|
|
|
|
micropython.heap_lock()
|
|
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")
|
|
|
|
print(micropython.heap_unlock())
|
|
|
|
# Should still fail
|
|
try:
|
|
print([])
|
|
except MemoryError:
|
|
print("MemoryError")
|
|
|
|
micropython.heap_unlock()
|
|
|
|
# check that allocation works after an unlock
|
|
print([])
|