tests/run-tests.py
changeset 27777 47ac135113ec
parent 27773 bf45edfa9d90
child 27880 b04df9ce1fb0
--- 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: