summaryrefslogtreecommitdiffstats
path: root/test/Value.py
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-02-14 19:42:00 (GMT)
committerMats Wichmann <mats@linux.com>2019-02-14 22:13:16 (GMT)
commit887f4a1b06ceed33ee6ba4c5589a32a607d6b001 (patch)
tree48de09819749eea0e8d134386892397809122769 /test/Value.py
parent334e11d04bb3be2f0ed93f929548e6cdc84c3158 (diff)
downloadSCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.zip
SCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.tar.gz
SCons-887f4a1b06ceed33ee6ba4c5589a32a607d6b001.tar.bz2
Clean up some tests: use context managers
Plenty of complaints coming from Python 3.8alpha on unclosed files. Targeted those areas which intersect with PyPy failures - this changeset reduces the PyPy fails by 17 on the local test environment. So this affects both Issue #3299 and the PyPy support project. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/Value.py')
-rw-r--r--test/Value.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/Value.py b/test/Value.py
index 34b036b..5a6a48e 100644
--- a/test/Value.py
+++ b/test/Value.py
@@ -48,7 +48,8 @@ L = len(P)
C = Custom(P)
def create(target, source, env):
- open(str(target[0]), 'wb').write(source[0].get_contents())
+ with open(str(target[0]), 'wb') as f:
+ f.write(source[0].get_contents())
env = Environment()
env['BUILDERS']['B'] = Builder(action = create)
@@ -62,7 +63,9 @@ def create_value (target, source, env):
target[0].write(source[0].get_contents())
def create_value_file (target, source, env):
- open(str(target[0]), 'wb').write(source[0].read())
+ #open(str(target[0]), 'wb').write(source[0].read())
+ with open(str(target[0]), 'wb') as f:
+ f.write(source[0].read())
env['BUILDERS']['B2'] = Builder(action = create_value)
env['BUILDERS']['B3'] = Builder(action = create_value_file)
@@ -75,7 +78,8 @@ env.B3('f5.out', V)
test.write('put.py', """\
import os
import sys
-open(sys.argv[-1],'w').write(" ".join(sys.argv[1:-2]))
+with open(sys.argv[-1],'w') as f:
+ f.write(" ".join(sys.argv[1:-2]))
""")
# Run all of the tests with both types of source signature