summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extmod/vfs_posix.py25
-rw-r--r--tests/extmod/vfs_posix.py.exp1
-rw-r--r--tests/io/file1.py3
3 files changed, 29 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)
diff --git a/tests/extmod/vfs_posix.py.exp b/tests/extmod/vfs_posix.py.exp
index 1b1f59b43..c0a4ed000 100644
--- a/tests/extmod/vfs_posix.py.exp
+++ b/tests/extmod/vfs_posix.py.exp
@@ -2,3 +2,4 @@
True
<class 'tuple'>
<class 'list'>
+hello
diff --git a/tests/io/file1.py b/tests/io/file1.py
index 2a46c9c63..de30045d3 100644
--- a/tests/io/file1.py
+++ b/tests/io/file1.py
@@ -44,3 +44,6 @@ try:
except OSError:
print("OSError")
f.close()
+
+# close() on a closed file
+f.close()