##// END OF EJS Templates
run-tests: use a context manager for file I/O
Bryan O'Sullivan -
r27773:bf45edfa default
parent child Browse files
Show More
@@ -1716,8 +1716,7 b' class TextTestRunner(unittest.TextTestRu'
1716 if json is None:
1716 if json is None:
1717 raise ImportError("json module not installed")
1717 raise ImportError("json module not installed")
1718 jsonpath = os.path.join(self._runner._testdir, 'report.json')
1718 jsonpath = os.path.join(self._runner._testdir, 'report.json')
1719 fp = open(jsonpath, 'w')
1719 with open(jsonpath, 'w') as fp:
1720 try:
1721 timesd = {}
1720 timesd = {}
1722 for tdata in result.times:
1721 for tdata in result.times:
1723 test = tdata[0]
1722 test = tdata[0]
@@ -1741,8 +1740,6 b' class TextTestRunner(unittest.TextTestRu'
1741 outcome[tc.name] = tres
1740 outcome[tc.name] = tres
1742 jsonout = json.dumps(outcome, sort_keys=True, indent=4)
1741 jsonout = json.dumps(outcome, sort_keys=True, indent=4)
1743 fp.writelines(("testreport =", jsonout))
1742 fp.writelines(("testreport =", jsonout))
1744 finally:
1745 fp.close()
1746
1743
1747 self._runner._checkhglib('Tested')
1744 self._runner._checkhglib('Tested')
1748
1745
General Comments 0
You need to be logged in to leave comments. Login now