diff options
author | Alex March <alex.march.dev@gmail.com> | 2016-10-07 10:19:04 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-10-11 16:03:52 +1100 |
commit | f274561e16dd35242d34c9b8fa7a09905857992c (patch) | |
tree | 88dcf1e5f0614e6917d3b5fe2d90f7ceb1d768e4 /tests | |
parent | d02f3a57f47b44bf31769fb089f1f18060ea3b4d (diff) | |
download | micropython-f274561e16dd35242d34c9b8fa7a09905857992c.tar.gz micropython-f274561e16dd35242d34c9b8fa7a09905857992c.zip |
tests/extmod/vfs_fat: Test coverage for remove() and rmdir().
Diffstat (limited to 'tests')
-rw-r--r-- | tests/extmod/vfs_fat_ramdisk.py | 26 | ||||
-rw-r--r-- | tests/extmod/vfs_fat_ramdisk.py.exp | 5 |
2 files changed, 30 insertions, 1 deletions
diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index f470dbcfe7..d11ad324fc 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -62,11 +62,22 @@ assert b"hello!" in bdev.data assert vfs.listdir() == ['foo_file.txt'] +try: + vfs.rmdir("foo_file.txt") +except OSError as e: + print(e.args[0] == 20) # uerrno.ENOTDIR + vfs.remove('foo_file.txt') assert vfs.listdir() == [] vfs.mkdir("foo_dir") assert vfs.listdir() == ['foo_dir'] + +try: + vfs.remove("foo_dir") +except OSError as e: + print(e.args[0] == uerrno.EISDIR) + f = vfs.open("foo_dir/file-in-dir.txt", "w") f.write("data in file") f.close() @@ -84,9 +95,22 @@ with vfs.open("sub_file.txt", "w") as f: f.write("test2") assert vfs.listdir() == ["sub_file.txt"] +try: + vfs.chdir("sub_file.txt") +except OSError as e: + print(e.args[0] == uerrno.ENOENT) + vfs.chdir("..") print("getcwd:", vfs.getcwd()) +try: + vfs.rmdir("foo_dir") +except OSError as e: + print(e.args[0] == uerrno.EACCES) + +vfs.remove("foo_dir/sub_file.txt") +vfs.rmdir("foo_dir") +print(vfs.listdir()) vfs.umount() try: @@ -97,4 +121,4 @@ else: raise AssertionError("expected OSError not thrown") vfs = uos.VfsFat(bdev, "/ramdisk") -assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt'] +assert vfs.listdir() == ['moved-to-root.txt'] diff --git a/tests/extmod/vfs_fat_ramdisk.py.exp b/tests/extmod/vfs_fat_ramdisk.py.exp index fd893b6e4c..ff16e5552d 100644 --- a/tests/extmod/vfs_fat_ramdisk.py.exp +++ b/tests/extmod/vfs_fat_ramdisk.py.exp @@ -1,5 +1,10 @@ statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255) getcwd: /ramdisk hello! +True +True getcwd: /ramdisk/foo_dir +True getcwd: /ramdisk +True +['moved-to-root.txt'] |