summaryrefslogtreecommitdiffstats
path: root/test/implicit/changed-node.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/implicit/changed-node.py')
-rw-r--r--test/implicit/changed-node.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/test/implicit/changed-node.py b/test/implicit/changed-node.py
index 8b818ba..c8c5a01 100644
--- a/test/implicit/changed-node.py
+++ b/test/implicit/changed-node.py
@@ -46,14 +46,13 @@ SetOption('max_drift', 1)
def lister(target, source, env):
import os
- fp = open(str(target[0]), 'w')
- s = str(source[0])
- if os.path.isdir(s):
- for l in os.listdir(str(source[0])):
- fp.write(l + '\\n')
- else:
- fp.write(s + '\\n')
- fp.close()
+ with open(str(target[0]), 'w') as ofp:
+ s = str(source[0])
+ if os.path.isdir(s):
+ for l in os.listdir(str(source[0])):
+ ofp.write(l + '\\n')
+ else:
+ ofp.write(s + '\\n')
builder = Builder(action=lister,
source_factory=Dir,
@@ -83,14 +82,13 @@ SetOption('max_drift', 1)
def lister(target, source, env):
import os.path
- fp = open(str(target[0]), 'w')
- s = str(source[0])
- if os.path.isdir(s):
- for l in os.listdir(str(source[0])):
- fp.write(l + '\\n')
- else:
- fp.write(s + '\\n')
- fp.close()
+ with open(str(target[0]), 'w') as ofp:
+ s = str(source[0])
+ if os.path.isdir(s):
+ for l in os.listdir(str(source[0])):
+ ofp.write(l + '\\n')
+ else:
+ ofp.write(s + '\\n')
builder = Builder(action=lister,
source_factory=File)
@@ -111,12 +109,12 @@ test.pass_test()
#
#
#def setfile(f, content):
-# f = open(f, 'w')
-# try: f.write(content)
-# finally: f.close()
+# with open(f, 'w') as ofp:
+# ofp.write(content)
#
#def checkfile(f, content):
-# assert open(f).read().strip() == content
+# with open(f) as fp:
+# assert fp.read().strip() == content
#
#def rm(f):
# if exists(f):