-
Notifications
You must be signed in to change notification settings - Fork 0
/
consolerobot.py
68 lines (55 loc) · 1.79 KB
/
consolerobot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from termcolor import colored
import xml.etree.ElementTree as ET
#TODO: 'output.xml' is the default filename
# robot writes. How about give it as a cmd line option?
root = ET.parse('output.xml').getroot()
#Indent of output
indentstr=" "
colours = {
'PASS': 'green',
'FAIL': 'red',
'Arg' : 'cyan',
'Doc' : 'yellow',
'Msg' : 'cyan'
}
def process_kw(keyword, indent):
status = keyword.find("status")
statusstr = status.attrib.get("status")
if( statusstr == "FAIL" ):
colour = colours['FAIL']
else:
colour = colours['PASS']
print(indent + colored(statusstr, colour) +": " + keyword.attrib.get("name"))
argstr=""
for arg in keyword.findall("arguments"):
for a in arg.findall("arg"):
argstr = argstr + a.text + colored("|", colours['Arg'])
if argstr:
print(indent + indentstr + colored("Args", colours['Arg']) + ": " + argstr )
for doc in keyword.findall("doc"):
print(indent+indentstr + colored("Doc", colours['Doc']) + ": " + doc.text)
for msg in keyword.findall("msg"):
if msg.text:
txt = msg.text.replace("\n", "\n" + indent+indentstr)
print(indent+indentstr + colored("Msg", colours['Msg']) + ": " + txt)
for subkw in keyword.findall("kw"):
process_kw(subkw, indent + indentstr)
def process_test(test):
print(indentstr + test.attrib.get("name"))
for keyword in test.findall("kw"):
process_kw(keyword, indentstr+indentstr)
print()
def process_suite(suite):
for subsuite in suite.findall('suite'):
print("Suite:" + subsuite.attrib.get("name"))
process_suite(subsuite)
for test in suite.findall("test"):
process_test(test)
# iterate over all suites
for suite in root.findall('suite'):
process_suite(suite)
for kw in suite.findall("kw"):
if( kw.attrib.get("type") == "teardown" ):
print(indentstr + "Suite teardown")
process_kw(kw, indentstr)
# vim: set noexpandtab: