diff options
Diffstat (limited to 'test/strfunction.py')
-rw-r--r-- | test/strfunction.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/strfunction.py b/test/strfunction.py index 8587dcb..04e23aa 100644 --- a/test/strfunction.py +++ b/test/strfunction.py @@ -36,7 +36,8 @@ test = TestSCons.TestSCons() test.write('cat.py', """\ import sys -open(sys.argv[2], "wb").write(open(sys.argv[1], "rb").read()) +with open(sys.argv[2], "wb") as f, open(sys.argv[1], "rb") as ifp: + f.write(ifp.read()) sys.exit(0) """) @@ -49,7 +50,8 @@ def strfunction(target, source, env): def func(target, source, env): t = str(target[0]) s = str(source[0]) - open(t, 'w').write(open(s, 'r').read()) + with open(t, 'w') as f, open(s, 'r') as ifp: + f.write(ifp.read()) func1action = Action(func, strfunction) func2action = Action(func, strfunction=strfunction) |