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.
This commit is contained in:
David Lechner
2020-03-22 21:26:08 -05:00
committed by Damien George
parent 488613bca6
commit 3dc324d3f1
472 changed files with 4396 additions and 2891 deletions

View File

@@ -2,12 +2,14 @@
try:
import uos
uos.VfsFat
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
class RAMBlockDevice:
ERASE_BLOCK_SIZE = 512
@@ -28,15 +30,16 @@ class RAMBlockDevice:
self.data[addr + i] = buf[i]
def ioctl(self, op, arg):
if op == 4: # block count
if op == 4: # block count
return len(self.data) // self.ERASE_BLOCK_SIZE
if op == 5: # block size
if op == 5: # block size
return self.ERASE_BLOCK_SIZE
if op == 6: # erase block
if op == 6: # erase block
return 0
def test(bdev, vfs_class):
print('test', vfs_class)
print("test", vfs_class)
# mkfs
vfs_class.mkfs(bdev)
@@ -45,21 +48,22 @@ def test(bdev, vfs_class):
vfs = vfs_class(bdev)
# statvfs
print(vfs.statvfs('/'))
print(vfs.statvfs("/"))
# open, write close
f = vfs.open('test', 'w')
f = vfs.open("test", "w")
for i in range(10):
f.write('some data')
f.write("some data")
f.close()
# ilistdir
print(list(vfs.ilistdir()))
# read
with vfs.open('test', 'r') as f:
with vfs.open("test", "r") as f:
print(f.read())
try:
bdev = RAMBlockDevice(50)
except MemoryError: