PythonExtra/tests/io/open_append.py
Paul Sokolovsky 5c34c2ff7f tests/io: Update tests to use uos.remove() instead of uos.unlink().
After Unix port switches from one to another, to be consistent with
baremetal ports.
2018-11-26 23:27:28 +11:00

38 lines
511 B
Python

try:
import uos as os
except ImportError:
import os
if not hasattr(os, "remove"):
print("SKIP")
raise SystemExit
# cleanup in case testfile exists
try:
os.remove("testfile")
except OSError:
pass
# Should create a file
f = open("testfile", "a")
f.write("foo")
f.close()
f = open("testfile")
print(f.read())
f.close()
f = open("testfile", "a")
f.write("bar")
f.close()
f = open("testfile")
print(f.read())
f.close()
# cleanup
try:
os.remove("testfile")
except OSError:
pass