diff options
author | Mats Wichmann <mats@linux.com> | 2019-02-14 19:42:00 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-02-14 22:13:16 (GMT) |
commit | 887f4a1b06ceed33ee6ba4c5589a32a607d6b001 (patch) | |
tree | 48de09819749eea0e8d134386892397809122769 /test/Batch/generated.py | |
parent | 334e11d04bb3be2f0ed93f929548e6cdc84c3158 (diff) | |
download | SCons-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/Batch/generated.py')
-rw-r--r-- | test/Batch/generated.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/Batch/generated.py b/test/Batch/generated.py index 21b8250..65ce8a8 100644 --- a/test/Batch/generated.py +++ b/test/Batch/generated.py @@ -36,10 +36,12 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ def batch_build(target, source, env): for t, s in zip(target, source): - fp = open(str(t), 'wb') - if str(t) == 'f3.out': - fp.write(open('f3.include', 'rb').read()) - fp.write(open(str(s), 'rb').read()) + with open(str(t), 'wb') as fp: + if str(t) == 'f3.out': + with open('f3.include', 'rb') as f: + fp.write(f.read()) + with open(str(s), 'rb') as f: + fp.write(f.read()) env = Environment() bb = Action(batch_build, batch_key=True) env['BUILDERS']['Batch'] = Builder(action=bb) |