diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-04-28 19:43:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 19:43:43 (GMT) |
commit | 35e6bbe16a859b42efca4592b435695a530f0717 (patch) | |
tree | 5a298b113bb1899e91583866b41eb9c337c0857e /test/implicit/changed-node.py | |
parent | 44c7b81e1a47ff5d4439740b1e929ea723ee1f18 (diff) | |
parent | 4ecdcf07580b1bfcd03f7886b6ab9256ee825175 (diff) | |
download | SCons-35e6bbe16a859b42efca4592b435695a530f0717.zip SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.gz SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.bz2 |
Merge pull request #3345 from mwichmann/py38warns4-tests
[wip] Py38warns4 tests
Diffstat (limited to 'test/implicit/changed-node.py')
-rw-r--r-- | test/implicit/changed-node.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/test/implicit/changed-node.py b/test/implicit/changed-node.py index 8b818ba..c8c5a01 100644 --- a/test/implicit/changed-node.py +++ b/test/implicit/changed-node.py @@ -46,14 +46,13 @@ SetOption('max_drift', 1) def lister(target, source, env): import os - fp = open(str(target[0]), 'w') - s = str(source[0]) - if os.path.isdir(s): - for l in os.listdir(str(source[0])): - fp.write(l + '\\n') - else: - fp.write(s + '\\n') - fp.close() + with open(str(target[0]), 'w') as ofp: + s = str(source[0]) + if os.path.isdir(s): + for l in os.listdir(str(source[0])): + ofp.write(l + '\\n') + else: + ofp.write(s + '\\n') builder = Builder(action=lister, source_factory=Dir, @@ -83,14 +82,13 @@ SetOption('max_drift', 1) def lister(target, source, env): import os.path - fp = open(str(target[0]), 'w') - s = str(source[0]) - if os.path.isdir(s): - for l in os.listdir(str(source[0])): - fp.write(l + '\\n') - else: - fp.write(s + '\\n') - fp.close() + with open(str(target[0]), 'w') as ofp: + s = str(source[0]) + if os.path.isdir(s): + for l in os.listdir(str(source[0])): + ofp.write(l + '\\n') + else: + ofp.write(s + '\\n') builder = Builder(action=lister, source_factory=File) @@ -111,12 +109,12 @@ test.pass_test() # # #def setfile(f, content): -# f = open(f, 'w') -# try: f.write(content) -# finally: f.close() +# with open(f, 'w') as ofp: +# ofp.write(content) # #def checkfile(f, content): -# assert open(f).read().strip() == content +# with open(f) as fp: +# assert fp.read().strip() == content # #def rm(f): # if exists(f): |