| 72 | |
| 73 | |
| 74 | def 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 | |
| 110 | if __name__ == "__main__": |