summaryrefslogtreecommitdiffstats
path: root/test/sconsign/nonwritable.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/sconsign/nonwritable.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/sconsign/nonwritable.py')
-rw-r--r--test/sconsign/nonwritable.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py
index 6f12f18..812a476 100644
--- a/test/sconsign/nonwritable.py
+++ b/test/sconsign/nonwritable.py
@@ -51,13 +51,15 @@ work2_sub3__sconsign = test.workpath('work2', 'sub3', '.sconsign')
SConstruct_contents = """\
def build1(target, source, env):
- open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ with open(str(target[0]), 'wb') as fo, open(str(source[0]), 'rb') as fi:
+ fo.write(fi.read())
return None
def build2(target, source, env):
import os
import os.path
- open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ with open(str(target[0]), 'wb') as fo, open(str(source[0]), 'rb') as fi:
+ fo.write(fi.read())
dir, file = os.path.split(str(target[0]))
os.chmod(dir, 0o555)
return None
@@ -92,8 +94,10 @@ test.write(['work2', 'SConstruct'], SConstruct_contents)
test.write(['work2', 'foo.in'], "work2/foo.in\n")
-pickle.dump({}, open(work2_sub1__sconsign, 'wb'), 1)
-pickle.dump({}, open(work2_sub2__sconsign, 'wb'), 1)
+with open(work2_sub1__sconsign, 'wb') as p:
+ pickle.dump({}, p, 1)
+with open(work2_sub2__sconsign, 'wb') as p:
+ pickle.dump({}, p, 1)
os.chmod(work2_sub1__sconsign, 0o444)