summaryrefslogtreecommitdiff
path: root/tests/extmod/vfs_posix.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-02-11 22:53:36 +1100
committerDamien George <damien@micropython.org>2021-02-11 22:54:41 +1100
commit26b4ef4c46520f595f39d53bbea7f247c9467370 (patch)
tree281d554ed78f489b3e38ed02638288e638b5f9c0 /tests/extmod/vfs_posix.py
parentc7aaee2b2ba0cb19d3b3deb6092e0bfe55d79052 (diff)
extmod/vfs_posix_file: Allow closing an already closed file.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/extmod/vfs_posix.py')
-rw-r--r--tests/extmod/vfs_posix.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/extmod/vfs_posix.py b/tests/extmod/vfs_posix.py
index 3bea99365..aea447e18 100644
--- a/tests/extmod/vfs_posix.py
+++ b/tests/extmod/vfs_posix.py
@@ -8,6 +8,15 @@ except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
+# We need a file for testing that doesn't already exist.
+# Skip the test if it does exist.
+temp_file = "micropy_test_file.txt"
+try:
+ uos.stat(temp_file)
+ print("SKIP")
+ raise SystemExit
+except OSError:
+ pass
# getcwd and chdir
curdir = uos.getcwd()
@@ -21,3 +30,19 @@ print(type(uos.stat("/")))
# listdir and ilistdir
print(type(uos.listdir("/")))
+
+# file create
+f = open(temp_file, "w")
+f.write("hello")
+f.close()
+
+# close on a closed file should succeed
+f.close()
+
+# file read
+f = open(temp_file, "r")
+print(f.read())
+f.close()
+
+# remove
+uos.remove(temp_file)