summaryrefslogtreecommitdiffstats
path: root/test/Repository/Local.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/Repository/Local.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/Repository/Local.py')
-rw-r--r--test/Repository/Local.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/Repository/Local.py b/test/Repository/Local.py
index 95fd898..7062075 100644
--- a/test/Repository/Local.py
+++ b/test/Repository/Local.py
@@ -49,7 +49,8 @@ def copy(env, source, target):
source = str(source[0])
target = str(target[0])
print('copy() < %s > %s' % (source, target))
- open(target, "w").write(open(source, "r").read())
+ with open(target, 'w') as fo, open(source, 'r') as fi:
+ fo.write(fi.read())
Build = Builder(action=copy)
env = Environment(BUILDERS={'Build':Build}, BBB='bbb')
@@ -66,7 +67,8 @@ test.write(['repository', 'src', 'SConscript'], r"""
def bbb_copy(env, source, target):
target = str(target[0])
print('bbb_copy()')
- open(target, "w").write(open('build/bbb.1', "r").read())
+ with open(target, 'w') as fo, open('build/bbb.1', 'r') as fi:
+ fo.write(fi.read())
Import("env")
env.Build('bbb.1', 'bbb.0')