Mercurial > hg-stable
changeset 27773:bf45edfa9d90
run-tests: use a context manager for file I/O
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 12 Jan 2016 14:29:57 -0800 |
parents | 00bd72629a45 |
children | 8ceaaf63ca80 |
files | tests/run-tests.py |
diffstat | 1 files changed, 1 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Tue Jan 12 14:29:34 2016 -0800 +++ b/tests/run-tests.py Tue Jan 12 14:29:57 2016 -0800 @@ -1716,8 +1716,7 @@ if json is None: raise ImportError("json module not installed") jsonpath = os.path.join(self._runner._testdir, 'report.json') - fp = open(jsonpath, 'w') - try: + with open(jsonpath, 'w') as fp: timesd = {} for tdata in result.times: test = tdata[0] @@ -1741,8 +1740,6 @@ outcome[tc.name] = tres jsonout = json.dumps(outcome, sort_keys=True, indent=4) fp.writelines(("testreport =", jsonout)) - finally: - fp.close() self._runner._checkhglib('Tested')