tests: Use .errno instead of .args[0] for OSError exceptions.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2021-04-22 19:32:21 +10:00
parent 342d55529d
commit 3123f6918b
19 changed files with 36 additions and 36 deletions

View File

@@ -51,22 +51,22 @@ uos.chdir("/ramdisk")
try:
vfs.mkdir("foo_dir")
except OSError as e:
print(e.args[0] == uerrno.EEXIST)
print(e.errno == uerrno.EEXIST)
try:
vfs.remove("foo_dir")
except OSError as e:
print(e.args[0] == uerrno.EISDIR)
print(e.errno == uerrno.EISDIR)
try:
vfs.remove("no_file.txt")
except OSError as e:
print(e.args[0] == uerrno.ENOENT)
print(e.errno == uerrno.ENOENT)
try:
vfs.rename("foo_dir", "/null/file")
except OSError as e:
print(e.args[0] == uerrno.ENOENT)
print(e.errno == uerrno.ENOENT)
# file in dir
with open("foo_dir/file-in-dir.txt", "w+t") as f:
@@ -82,7 +82,7 @@ with open("foo_dir/sub_file.txt", "w") as f:
try:
vfs.rmdir("foo_dir")
except OSError as e:
print(e.args[0] == uerrno.EACCES)
print(e.errno == uerrno.EACCES)
# trim full path
vfs.rename("foo_dir/file-in-dir.txt", "foo_dir/file.txt")
@@ -111,5 +111,5 @@ try:
f = open("large_file.txt", "wb")
f.write(bytearray(bsize * free))
except OSError as e:
print("ENOSPC:", e.args[0] == 28) # uerrno.ENOSPC
print("ENOSPC:", e.errno == 28) # uerrno.ENOSPC
f.close()