MCPcopy Create free account
hub / github.com/apache/cloudstack / parse_reports

Function parse_reports

tools/marvin/xunit-reader.py:74–107  ·  view source on GitHub ↗
(file_path_list)

Source from the content-addressed store, hash-verified

72
73
74def parse_reports(file_path_list):
75 table = texttable.Texttable()
76 table.header(['Test', 'Result', 'Time', 'Test file'])
77
78 exit_code = 0
79
80 for file_path in file_path_list:
81 data = lxml.etree.iterparse(file_path, tag='testcase', huge_tree=True)
82 for event, elem in data:
83 name = ''
84 status = 'Success'
85 time = ''
86 if 'name' in elem.attrib:
87 name = elem.attrib['name']
88 if 'time' in elem.attrib:
89 time = elem.attrib['time']
90 for children in elem.getchildren():
91 if 'skipped' == children.tag:
92 status = 'Skipped'
93 elif 'failure' == children.tag:
94 exit_code = 1
95 status = 'Failure'
96 elif 'error' == children.tag:
97 exit_code = 1
98 status = 'Error'
99 if 'type' in children.attrib:
100 status = children.attrib['type']
101
102 if status not in ('Skipped', 'Success'):
103 table.add_row([name, status, time, file_path.replace(".xml", "").split("/")[-1]])
104
105 print(table.draw())
106
107 return exit_code
108
109
110if __name__ == "__main__":

Callers 1

mainFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected