diff options
| author | David Lechner | 2020-03-22 21:26:08 -0500 |
|---|---|---|
| committer | Damien George | 2020-03-30 13:21:58 +1100 |
| commit | 3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch) | |
| tree | 94ff44f8eabba0039582c245b901173597edd11e /tests/extmod/vfs_fat_finaliser.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/extmod/vfs_fat_finaliser.py')
| -rw-r--r-- | tests/extmod/vfs_fat_finaliser.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/extmod/vfs_fat_finaliser.py b/tests/extmod/vfs_fat_finaliser.py index c7254c5f0..e30f42f84 100644 --- a/tests/extmod/vfs_fat_finaliser.py +++ b/tests/extmod/vfs_fat_finaliser.py @@ -2,6 +2,7 @@ try: import uerrno, uos + uos.VfsFat except (ImportError, AttributeError): print("SKIP") @@ -22,9 +23,9 @@ class RAMBlockDevice: self.data[n * self.sec_size + i] = buf[i] def ioctl(self, op, arg): - if op == 4: # MP_BLOCKDEV_IOCTL_BLOCK_COUNT + if op == 4: # MP_BLOCKDEV_IOCTL_BLOCK_COUNT return len(self.data) // self.sec_size - if op == 5: # MP_BLOCKDEV_IOCTL_BLOCK_SIZE + if op == 5: # MP_BLOCKDEV_IOCTL_BLOCK_SIZE return self.sec_size @@ -44,23 +45,25 @@ vfs = uos.VfsFat(bdev) # finaliser is a different path to normal allocation. It would be better to # test this in the core tests but there are no core objects that use finaliser. import micropython + micropython.heap_lock() try: - vfs.open('x', 'r') + vfs.open("x", "r") except MemoryError: - print('MemoryError') + print("MemoryError") micropython.heap_unlock() # Here we test that the finaliser is actually called during a garbage collection. import gc + N = 4 for i in range(N): - n = 'x%d' % i - f = vfs.open(n, 'w') + n = "x%d" % i + f = vfs.open(n, "w") f.write(n) - f = None # release f without closing - [0, 1, 2, 3] # use up Python stack so f is really gone -gc.collect() # should finalise all N files by closing them + f = None # release f without closing + [0, 1, 2, 3] # use up Python stack so f is really gone +gc.collect() # should finalise all N files by closing them for i in range(N): - with vfs.open('x%d' % i, 'r') as f: + with vfs.open("x%d" % i, "r") as f: print(f.read()) |
