r.append(table)
return r
+def xml_fail_tag_to_html_table(root):
+ if len(root.xpath('//*[@result="failure"]'))==0:
+ return [];
+
+ table = E.TABLE({'border':'1'}, E.TR(E.TH('Function line'), E.TH('Test case'),
+ E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+ r = []
+ r += [E.P("Fail : " + str(len(root.xpath('//*[@result="failure"]'))), style="font-weight: bold; font-size: 120%")]
+ for i in root.xpath('//*[@result="failure"]'):
+ table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+ E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+ r.append(table)
+ return r
+
+def xml_error_tag_to_html_table(root):
+ if len(root.xpath('//*[@result="error"]'))==0:
+ return [];
+
+ table = E.TABLE({'border':'1'}, E.TR(E.TH('Function line'), E.TH('Test case'),
+ E.TH("Result"), E.TH("Message"), E.TH("Duration"), bgcolor= "#d3d3d3"))
+ r = []
+ r += [E.P("Error : " + str(len(root.xpath('//*[@result="error"]'))), style="font-weight: bold; font-size: 120%")]
+ for i in root.xpath('//*[@result="error"]'):
+ table.append(E.TR(E.TD(i.find('fn').text), E.TD(i.find('id').text), E.TD(i.attrib['result']),
+ E.TD(i.find('message').text), E.TD(i.find('duration').text), bgcolor = table_in_color(i.attrib['result'])))
+
+ r.append(table)
+ return r
+
+
with open(sys.argv[1],'r') as f: e = fromstring(f.read())
html = E.HTML(
)
)
+
+for i in xml_fail_tag_to_html_table(e):
+ html.body.append(i)
+
+for i in xml_error_tag_to_html_table(e):
+ html.body.append(i)
+
for i in e.xpath('//suite'):
for j in xml_tag_to_html_table(i):
html.body.append(j)