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/extmod/vfs_lfs_error.py | |
parent | 488613bca6c460340ed2995ae5cafafe22d0bfff (diff) | |
download | micropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.tar.gz micropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.zip |
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_lfs_error.py')
-rw-r--r-- | tests/extmod/vfs_lfs_error.py | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/tests/extmod/vfs_lfs_error.py b/tests/extmod/vfs_lfs_error.py index 793fae59e2..717284ea01 100644 --- a/tests/extmod/vfs_lfs_error.py +++ b/tests/extmod/vfs_lfs_error.py @@ -2,12 +2,14 @@ try: import uos + uos.VfsLfs1 uos.VfsLfs2 except (ImportError, AttributeError): print("SKIP") raise SystemExit + class RAMBlockDevice: ERASE_BLOCK_SIZE = 1024 @@ -25,92 +27,94 @@ 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 with too-small block device try: vfs_class.mkfs(RAMBlockDevice(1)) except OSError: - print('mkfs OSError') + print("mkfs OSError") # mount with invalid filesystem try: vfs_class(bdev) except OSError: - print('mount OSError') + print("mount OSError") # set up for following tests vfs_class.mkfs(bdev) vfs = vfs_class(bdev) - with vfs.open('testfile', 'w') as f: - f.write('test') - vfs.mkdir('testdir') + with vfs.open("testfile", "w") as f: + f.write("test") + vfs.mkdir("testdir") # ilistdir try: - vfs.ilistdir('noexist') + vfs.ilistdir("noexist") except OSError: - print('ilistdir OSError') + print("ilistdir OSError") # remove try: - vfs.remove('noexist') + vfs.remove("noexist") except OSError: - print('remove OSError') + print("remove OSError") # rmdir try: - vfs.rmdir('noexist') + vfs.rmdir("noexist") except OSError: - print('rmdir OSError') + print("rmdir OSError") # rename try: - vfs.rename('noexist', 'somethingelse') + vfs.rename("noexist", "somethingelse") except OSError: - print('rename OSError') + print("rename OSError") # mkdir try: - vfs.mkdir('testdir') + vfs.mkdir("testdir") except OSError: - print('mkdir OSError') + print("mkdir OSError") # chdir to nonexistent try: - vfs.chdir('noexist') + vfs.chdir("noexist") except OSError: - print('chdir OSError') - print(vfs.getcwd()) # check still at root + print("chdir OSError") + print(vfs.getcwd()) # check still at root # chdir to file try: - vfs.chdir('testfile') + vfs.chdir("testfile") except OSError: - print('chdir OSError') - print(vfs.getcwd()) # check still at root + print("chdir OSError") + print(vfs.getcwd()) # check still at root # stat try: - vfs.stat('noexist') + vfs.stat("noexist") except OSError: - print('stat OSError') + print("stat OSError") # error during seek - with vfs.open('testfile', 'r') as f: - f.seek(1 << 30) # SEEK_SET + with vfs.open("testfile", "r") as f: + f.seek(1 << 30) # SEEK_SET try: - f.seek(1 << 30, 1) # SEEK_CUR + f.seek(1 << 30, 1) # SEEK_CUR except OSError: - print('seek OSError') + print("seek OSError") + bdev = RAMBlockDevice(30) test(bdev, uos.VfsLfs1) |