diff options
author | David Lechner <david@lechnology.com> | 2020-03-22 21:26:08 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-03-30 13:21:58 +1100 |
commit | 3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch) | |
tree | 94ff44f8eabba0039582c245b901173597edd11e /tests/micropython/heapalloc_fail_bytearray.py | |
parent | 488613bca6c460340ed2995ae5cafafe22d0bfff (diff) |
tests: Format all Python code with black, except tests in basics subdir.
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.
Diffstat (limited to 'tests/micropython/heapalloc_fail_bytearray.py')
-rw-r--r-- | tests/micropython/heapalloc_fail_bytearray.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/tests/micropython/heapalloc_fail_bytearray.py b/tests/micropython/heapalloc_fail_bytearray.py index fbf585c7f..1bf7ddd60 100644 --- a/tests/micropython/heapalloc_fail_bytearray.py +++ b/tests/micropython/heapalloc_fail_bytearray.py @@ -2,9 +2,12 @@ import micropython + class GetSlice: def __getitem__(self, idx): return idx + + sl = GetSlice()[:] # create bytearray @@ -12,15 +15,15 @@ micropython.heap_lock() try: bytearray(4) except MemoryError: - print('MemoryError: bytearray create') + print("MemoryError: bytearray create") micropython.heap_unlock() # create bytearray from bytes micropython.heap_lock() try: - bytearray(b'0123') + bytearray(b"0123") except MemoryError: - print('MemoryError: bytearray create from bytes') + print("MemoryError: bytearray create from bytes") micropython.heap_unlock() # create bytearray from iterator @@ -29,25 +32,25 @@ micropython.heap_lock() try: bytearray(r) except MemoryError: - print('MemoryError: bytearray create from iter') + print("MemoryError: bytearray create from iter") micropython.heap_unlock() # bytearray add b = bytearray(4) micropython.heap_lock() try: - b + b'01' + b + b"01" except MemoryError: - print('MemoryError: bytearray.__add__') + print("MemoryError: bytearray.__add__") micropython.heap_unlock() # bytearray iadd b = bytearray(4) micropython.heap_lock() try: - b += b'01234567' + b += b"01234567" except MemoryError: - print('MemoryError: bytearray.__iadd__') + print("MemoryError: bytearray.__iadd__") micropython.heap_unlock() print(b) @@ -58,16 +61,16 @@ try: for i in range(100): b.append(1) except MemoryError: - print('MemoryError: bytearray.append') + print("MemoryError: bytearray.append") micropython.heap_unlock() # bytearray extend b = bytearray(4) micropython.heap_lock() try: - b.extend(b'01234567') + b.extend(b"01234567") except MemoryError: - print('MemoryError: bytearray.extend') + print("MemoryError: bytearray.extend") micropython.heap_unlock() # bytearray get with slice @@ -76,15 +79,15 @@ micropython.heap_lock() try: b[sl] except MemoryError: - print('MemoryError: bytearray subscr get') + print("MemoryError: bytearray subscr get") micropython.heap_unlock() # extend bytearray using slice subscr b = bytearray(4) micropython.heap_lock() try: - b[sl] = b'01234567' + b[sl] = b"01234567" except MemoryError: - print('MemoryError: bytearray subscr grow') + print("MemoryError: bytearray subscr grow") micropython.heap_unlock() print(b) |