Lines 1-51
Link Here
|
1 |
#!/usr/bin/env python |
|
|
2 |
|
3 |
import sys |
4 |
import math |
5 |
import xml.etree.ElementTree as et |
6 |
|
7 |
|
8 |
def parse_results(filename): |
9 |
tree = et.parse(filename) |
10 |
root = tree.getroot() |
11 |
skipped = [] |
12 |
|
13 |
current_class = old_class = '' |
14 |
i = 1 |
15 |
assert i - 1 == len(skipped) |
16 |
for el in root.findall('testcase'): |
17 |
cn = el.attrib['classname'] |
18 |
for sk in el.findall('skipped'): |
19 |
old_class = current_class |
20 |
current_class = cn |
21 |
name = '{classname}.{name}'.format(classname=current_class, |
22 |
name=el.attrib['name']) |
23 |
msg = sk.attrib['message'] |
24 |
out = '' |
25 |
if old_class != current_class: |
26 |
ndigits = int(math.log(i, 10) + 1) |
27 |
out += ('-' * (len(name + msg) + 4 + ndigits) + '\n') # 4 for : + space + # + space |
28 |
out += '#{i} {name}: {msg}'.format(i=i, name=name, msg=msg) |
29 |
skipped.append(out) |
30 |
i += 1 |
31 |
assert i - 1 == len(skipped) |
32 |
assert i - 1 == len(skipped) |
33 |
assert len(skipped) == int(root.attrib['skip']) |
34 |
return '\n'.join(skipped) |
35 |
|
36 |
|
37 |
def main(args): |
38 |
print('SKIPPED TESTS:') |
39 |
print(parse_results(args.filename)) |
40 |
return 0 |
41 |
|
42 |
|
43 |
def parse_args(): |
44 |
import argparse |
45 |
parser = argparse.ArgumentParser() |
46 |
parser.add_argument('filename', help='XUnit file to parse') |
47 |
return parser.parse_args() |
48 |
|
49 |
|
50 |
if __name__ == '__main__': |
51 |
sys.exit(main(parse_args())) |