summaryrefslogtreecommitdiffstats
path: root/test/CacheDir/option--cr.py
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-03-02 17:45:34 (GMT)
committerMats Wichmann <mats@linux.com>2019-03-02 17:45:34 (GMT)
commit4d40813e369694fbe3cfe5488178bbb722d67319 (patch)
treed58d6b184d4ca4fc84612c02091fce35dc6a9f90 /test/CacheDir/option--cr.py
parentfedd3ecc0921b9a4ec8dda6aba3f2de726f79345 (diff)
downloadSCons-4d40813e369694fbe3cfe5488178bbb722d67319.zip
SCons-4d40813e369694fbe3cfe5488178bbb722d67319.tar.gz
SCons-4d40813e369694fbe3cfe5488178bbb722d67319.tar.bz2
[PYPY3] [PY 3.8] CacheDir tests use context managers
Python 3.8 complains about unclosed files on nearly all of the CacheDir tests. PyPy3 fails 8 of the 20 tests for the same reason, though since it's based on an earlier version of Python (3.5 at the moment) it does not display the resourcewarning messages. Update sequences of open().write() which are the primary problem area to use context managers for automatic closing, and for consistency, the rest of the open/read/write stuff as well. With this change, all these tests pass in PyPy3. Python 3.8 does not, as it is spewing other warning messages which also end up in the stderr, which is fatal to this set of tests, but it has quieted the warnings from the CacheDir tests themselves. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/CacheDir/option--cr.py')
-rw-r--r--test/CacheDir/option--cr.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/CacheDir/option--cr.py b/test/CacheDir/option--cr.py
index 4ed587c..b7696c5 100644
--- a/test/CacheDir/option--cr.py
+++ b/test/CacheDir/option--cr.py
@@ -42,11 +42,12 @@ test.write(['src', 'SConstruct'], """
DefaultEnvironment(tools=[])
def cat(env, source, target):
target = str(target[0])
- open('cat.out', 'a').write(target + "\\n")
- f = open(target, "w")
- for src in source:
- f.write(open(str(src), "r").read())
- f.close()
+ with open('cat.out', 'a') as f:
+ f.write(target + "\\n")
+ with open(target, "w") as f:
+ for src in source:
+ with open(str(src), "r") as f2:
+ f.write(f2.read())
env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)})
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')