You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
tests: Add testcase for open(..., "a").
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import sys
|
||||
try:
|
||||
import _os as os
|
||||
except ImportError:
|
||||
import os
|
||||
|
||||
if not hasattr(os, "unlink"):
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
os.unlink("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()
|
||||
Reference in New Issue
Block a user