Mercurial > public > mercurial-scm > hg-stable
diff tests/run-tests.py @ 27777:47ac135113ec
run-tests: use a context manager for file I/O in TextTestRunner
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 12 Jan 2016 14:49:10 -0800 |
parents | bf45edfa9d90 |
children | b04df9ce1fb0 |
line wrap: on
line diff
--- a/tests/run-tests.py Tue Jan 12 14:48:27 2016 -0800 +++ b/tests/run-tests.py Tue Jan 12 14:49:10 2016 -0800 @@ -1681,8 +1681,7 @@ self.stream.writeln('Errored %s: %s' % (test.name, msg)) if self._runner.options.xunit: - xuf = open(self._runner.options.xunit, 'wb') - try: + with open(self._runner.options.xunit, 'wb') as xuf: timesd = dict((t[0], t[3]) for t in result.times) doc = minidom.Document() s = doc.createElement('testsuite') @@ -1709,8 +1708,6 @@ t.appendChild(cd) s.appendChild(t) xuf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) - finally: - xuf.close() if self._runner.options.json: if json is None: