2022-08-18 07:57:45 +01:00
|
|
|
import os
|
2015-06-20 22:02:41 +01:00
|
|
|
|
2018-11-26 05:52:18 +00:00
|
|
|
if not hasattr(os, "remove"):
|
2015-06-20 22:02:41 +01:00
|
|
|
print("SKIP")
|
2017-06-10 18:14:16 +01:00
|
|
|
raise SystemExit
|
2015-06-20 22:02:41 +01:00
|
|
|
|
2015-08-21 08:45:52 +01:00
|
|
|
# cleanup in case testfile exists
|
2015-06-20 22:02:41 +01:00
|
|
|
try:
|
2018-11-26 05:52:18 +00:00
|
|
|
os.remove("testfile")
|
2015-06-20 22:02:41 +01:00
|
|
|
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()
|
2015-08-21 08:45:52 +01:00
|
|
|
|
|
|
|
# cleanup
|
|
|
|
try:
|
2018-11-26 05:52:18 +00:00
|
|
|
os.remove("testfile")
|
2015-08-21 08:45:52 +01:00
|
|
|
except OSError:
|
|
|
|
pass
|