Browse Source

tests/extmod/vfs_fat: Replace asserts with prints and expected outputs.

pull/2507/merge
Alex March 8 years ago
committed by Paul Sokolovsky
parent
commit
e42186d356
  1. 28
      tests/extmod/vfs_fat_ramdisk.py
  2. 13
      tests/extmod/vfs_fat_ramdisk.py.exp

28
tests/extmod/vfs_fat_ramdisk.py

@ -41,8 +41,8 @@ except MemoryError:
uos.VfsFat.mkfs(bdev)
assert b"FOO_FILETXT" not in bdev.data
assert b"hello!" not in bdev.data
print(b"FOO_FILETXT" not in bdev.data)
print(b"hello!" not in bdev.data)
vfs = uos.VfsFat(bdev, "/ramdisk")
print("statvfs:", vfs.statvfs("/ramdisk"))
@ -57,10 +57,10 @@ f2 = vfs.open("foo_file.txt")
print(f2.read())
f2.close()
assert b"FOO_FILETXT" in bdev.data
assert b"hello!" in bdev.data
print(b"FOO_FILETXT" in bdev.data)
print(b"hello!" in bdev.data)
assert vfs.listdir() == ['foo_file.txt']
print(vfs.listdir())
try:
vfs.rmdir("foo_file.txt")
@ -68,10 +68,10 @@ except OSError as e:
print(e.args[0] == 20) # uerrno.ENOTDIR
vfs.remove('foo_file.txt')
assert vfs.listdir() == []
print(vfs.listdir())
vfs.mkdir("foo_dir")
assert vfs.listdir() == ['foo_dir']
print(vfs.listdir())
try:
vfs.remove("foo_dir")
@ -82,18 +82,18 @@ f = vfs.open("foo_dir/file-in-dir.txt", "w")
f.write("data in file")
f.close()
assert vfs.listdir("foo_dir") == ['file-in-dir.txt']
print(vfs.listdir("foo_dir"))
vfs.rename("foo_dir/file-in-dir.txt", "moved-to-root.txt")
assert vfs.listdir() == ['foo_dir', 'moved-to-root.txt']
print(vfs.listdir())
vfs.chdir("foo_dir")
print("getcwd:", vfs.getcwd())
assert vfs.listdir() == []
print(vfs.listdir())
with vfs.open("sub_file.txt", "w") as f:
f.write("test2")
assert vfs.listdir() == ["sub_file.txt"]
print(vfs.listdir())
try:
vfs.chdir("sub_file.txt")
@ -116,9 +116,7 @@ vfs.umount()
try:
vfs.listdir()
except OSError as e:
assert e.args[0] == uerrno.ENODEV
else:
raise AssertionError("expected OSError not thrown")
print(e.args[0] == uerrno.ENODEV)
vfs = uos.VfsFat(bdev, "/ramdisk")
assert vfs.listdir() == ['moved-to-root.txt']
print(vfs.listdir())

13
tests/extmod/vfs_fat_ramdisk.py.exp

@ -1,10 +1,23 @@
True
True
statvfs: (512, 512, 14, 14, 14, 0, 0, 0, 0, 255)
getcwd: /ramdisk
hello!
True
True
['foo_file.txt']
True
[]
['foo_dir']
True
['file-in-dir.txt']
['foo_dir', 'moved-to-root.txt']
getcwd: /ramdisk/foo_dir
[]
['sub_file.txt']
True
getcwd: /ramdisk
True
['moved-to-root.txt']
True
['moved-to-root.txt']

Loading…
Cancel
Save