tests/run-tests.py
changeset 27773 bf45edfa9d90
parent 27689 50e621fe0362
child 27777 47ac135113ec
--- 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')