def main(start): totals = TestResults() html_writer = HtmlOutlineWriter(sys.stdout) for dirpath, _, filenames in os.walk(start): for name in ["nosetests.xml", "xunit.xml"]: if name in filenames: results = report_file(os.path.join(dirpath, name), html_writer) totals += results html_writer.write(escape(str(totals)))
def main(input_files, output_file): os.makedirs(os.path.dirname(output_file)) out_suite = etree.fromstring("<testsuite></testsuite>") tree = etree.ElementTree(out_suite) totals = TestResults() for input_file in input_files: with open(input_file) as in_xml: in_tree = etree.parse(in_xml) for testsuite in in_tree.xpath("/testsuite"): totals += TestResults.from_element(testsuite) for testcase in testsuite.xpath("testcase"): out_suite.append(testcase) totals.onto_element(out_suite) with open(output_file, "w") as out_xml: out_xml.write( etree.tostring(tree, pretty_print=True, xml_declaration=True, encoding="utf8"))