diff options
author | Mats Wichmann <mats@linux.com> | 2019-03-31 07:01:00 -0600 |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-04-25 09:37:04 -0600 |
commit | f61d3bcd112285644c1a6ce253b267ef690a7e06 (patch) | |
tree | 2e489e238c11697f602cb9a7cbeb43afed088734 /test/AS | |
parent | b0c3385604ebc1d7d552472f1cc6d0910aafa32a (diff) | |
download | scons-git-f61d3bcd112285644c1a6ce253b267ef690a7e06.tar.gz |
[PY 3.8] test fixes for file closings, rawstrings
On a linux host (missing some things that may be on the Travis CI
setup), Py3.8a3 now shows 19 fails, 1048 pass, with 84 Warning: messages.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/AS')
-rw-r--r-- | test/AS/as-live.py | 3 | ||||
-rw-r--r-- | test/AS/fixture/myas.py | 18 | ||||
-rw-r--r-- | test/AS/fixture/myas_args.py | 23 |
3 files changed, 20 insertions, 24 deletions
diff --git a/test/AS/as-live.py b/test/AS/as-live.py index 879e7b22d..b781cafc2 100644 --- a/test/AS/as-live.py +++ b/test/AS/as-live.py @@ -58,7 +58,8 @@ if sys.platform == "win32": test.write("wrapper.py", """\ import os import sys -open('%s', 'wb').write(("wrapper.py: %%s\\n" %% sys.argv[-1]).encode()) +with open('%s', 'wb') as f: + f.write(("wrapper.py: %%s\\n" %% sys.argv[-1]).encode()) cmd = " ".join(sys.argv[1:]) os.system(cmd) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) diff --git a/test/AS/fixture/myas.py b/test/AS/fixture/myas.py index bffae7821..4f5d9ac1c 100644 --- a/test/AS/fixture/myas.py +++ b/test/AS/fixture/myas.py @@ -15,11 +15,10 @@ if sys.platform == 'win32': inf = a continue if a[:3] == '/Fo': out = a[3:] - infile = open(inf, 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) + with open(inf, 'rb') as ifp, open(out, 'wb') as ofp: + for l in ifp.readlines(): + if l[:3] != b'#as': + ofp.write(l) sys.exit(0) else: @@ -27,9 +26,8 @@ else: opts, args = getopt.getopt(sys.argv[1:], 'co:') for opt, arg in opts: if opt == '-o': out = arg - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) + with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp: + for l in ifp.readlines(): + if l[:3] != b'#as': + ofp.write(l) sys.exit(0) diff --git a/test/AS/fixture/myas_args.py b/test/AS/fixture/myas_args.py index c7ca31534..24d68dc8f 100644 --- a/test/AS/fixture/myas_args.py +++ b/test/AS/fixture/myas_args.py @@ -21,12 +21,11 @@ if sys.platform == 'win32': out = a[3:] continue optstring = optstring + ' ' + a - infile = open(inf, 'rb') - outfile = open(out, 'wb') - outfile.write(bytearray(optstring + "\n",'utf-8')) - for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) + with open(inf, 'rb') as ifp, open(out, 'wb') as ofp: + ofp.write(bytearray(optstring + "\n",'utf-8')) + for l in ifp.readlines(): + if l[:3] != b'#as': + ofp.write(l) sys.exit(0) else: import getopt @@ -37,12 +36,10 @@ else: if opt == '-o': out = arg else: optstring = optstring + ' ' + opt - infile = open(args[0], 'rb') - outfile = open(out, 'wb') - outfile.write(bytearray(optstring + "\n",'utf-8')) - - for l in infile.readlines(): - if l[:3] != b'#as': - outfile.write(l) + with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp: + ofp.write(bytearray(optstring + "\n",'utf-8')) + for l in ifp.readlines(): + if l[:3] != b'#as': + ofp.write(l) sys.exit(0) |