Show More
@@ -1938,36 +1938,7 b' class TextTestRunner(unittest.TextTestRu' | |||||
1938 | if self._runner.options.json: |
|
1938 | if self._runner.options.json: | |
1939 | jsonpath = os.path.join(self._runner._testdir, b'report.json') |
|
1939 | jsonpath = os.path.join(self._runner._testdir, b'report.json') | |
1940 | with open(jsonpath, 'w') as fp: |
|
1940 | with open(jsonpath, 'w') as fp: | |
1941 |
|
|
1941 | self._writejson(result, fp) | |
1942 | for tdata in result.times: |
|
|||
1943 | test = tdata[0] |
|
|||
1944 | timesd[test] = tdata[1:] |
|
|||
1945 |
|
||||
1946 | outcome = {} |
|
|||
1947 | groups = [('success', ((tc, None) |
|
|||
1948 | for tc in result.successes)), |
|
|||
1949 | ('failure', result.failures), |
|
|||
1950 | ('skip', result.skipped)] |
|
|||
1951 | for res, testcases in groups: |
|
|||
1952 | for tc, __ in testcases: |
|
|||
1953 | if tc.name in timesd: |
|
|||
1954 | diff = result.faildata.get(tc.name, b'') |
|
|||
1955 | tres = {'result': res, |
|
|||
1956 | 'time': ('%0.3f' % timesd[tc.name][2]), |
|
|||
1957 | 'cuser': ('%0.3f' % timesd[tc.name][0]), |
|
|||
1958 | 'csys': ('%0.3f' % timesd[tc.name][1]), |
|
|||
1959 | 'start': ('%0.3f' % timesd[tc.name][3]), |
|
|||
1960 | 'end': ('%0.3f' % timesd[tc.name][4]), |
|
|||
1961 | 'diff': diff.decode('unicode_escape'), |
|
|||
1962 | } |
|
|||
1963 | else: |
|
|||
1964 | # blacklisted test |
|
|||
1965 | tres = {'result': res} |
|
|||
1966 |
|
||||
1967 | outcome[tc.name] = tres |
|
|||
1968 | jsonout = json.dumps(outcome, sort_keys=True, indent=4, |
|
|||
1969 | separators=(',', ': ')) |
|
|||
1970 | fp.writelines(("testreport =", jsonout)) |
|
|||
1971 |
|
1942 | |||
1972 | self._runner._checkhglib('Tested') |
|
1943 | self._runner._checkhglib('Tested') | |
1973 |
|
1944 | |||
@@ -2060,6 +2031,39 b' class TextTestRunner(unittest.TextTestRu' | |||||
2060 | s.appendChild(t) |
|
2031 | s.appendChild(t) | |
2061 | outf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) |
|
2032 | outf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) | |
2062 |
|
2033 | |||
|
2034 | @staticmethod | |||
|
2035 | def _writejson(result, outf): | |||
|
2036 | timesd = {} | |||
|
2037 | for tdata in result.times: | |||
|
2038 | test = tdata[0] | |||
|
2039 | timesd[test] = tdata[1:] | |||
|
2040 | ||||
|
2041 | outcome = {} | |||
|
2042 | groups = [('success', ((tc, None) | |||
|
2043 | for tc in result.successes)), | |||
|
2044 | ('failure', result.failures), | |||
|
2045 | ('skip', result.skipped)] | |||
|
2046 | for res, testcases in groups: | |||
|
2047 | for tc, __ in testcases: | |||
|
2048 | if tc.name in timesd: | |||
|
2049 | diff = result.faildata.get(tc.name, b'') | |||
|
2050 | tres = {'result': res, | |||
|
2051 | 'time': ('%0.3f' % timesd[tc.name][2]), | |||
|
2052 | 'cuser': ('%0.3f' % timesd[tc.name][0]), | |||
|
2053 | 'csys': ('%0.3f' % timesd[tc.name][1]), | |||
|
2054 | 'start': ('%0.3f' % timesd[tc.name][3]), | |||
|
2055 | 'end': ('%0.3f' % timesd[tc.name][4]), | |||
|
2056 | 'diff': diff.decode('unicode_escape'), | |||
|
2057 | } | |||
|
2058 | else: | |||
|
2059 | # blacklisted test | |||
|
2060 | tres = {'result': res} | |||
|
2061 | ||||
|
2062 | outcome[tc.name] = tres | |||
|
2063 | jsonout = json.dumps(outcome, sort_keys=True, indent=4, | |||
|
2064 | separators=(',', ': ')) | |||
|
2065 | outf.writelines(("testreport =", jsonout)) | |||
|
2066 | ||||
2063 | class TestRunner(object): |
|
2067 | class TestRunner(object): | |
2064 | """Holds context for executing tests. |
|
2068 | """Holds context for executing tests. | |
2065 |
|
2069 |
General Comments 0
You need to be logged in to leave comments.
Login now