|
1 | 1 | #!/usr/bin/env python
|
2 |
| - |
3 |
| -import math |
4 | 2 | import os
|
5 |
| -import sys |
6 | 3 | import xml.etree.ElementTree as et
|
7 | 4 |
|
8 | 5 |
|
9 |
| -def parse_results(filename): |
| 6 | +def main(filename): |
| 7 | + if not os.path.isfile(filename): |
| 8 | + return |
| 9 | + |
10 | 10 | tree = et.parse(filename)
|
11 | 11 | root = tree.getroot()
|
12 |
| - skipped = [] |
13 |
| - |
14 | 12 | current_class = ""
|
15 |
| - i = 1 |
16 |
| - assert i - 1 == len(skipped) |
17 | 13 | for el in root.findall("testcase"):
|
18 | 14 | cn = el.attrib["classname"]
|
19 | 15 | for sk in el.findall("skipped"):
|
20 | 16 | old_class = current_class
|
21 | 17 | current_class = cn
|
22 |
| - name = "{classname}.{name}".format( |
23 |
| - classname=current_class, name=el.attrib["name"] |
24 |
| - ) |
25 |
| - msg = sk.attrib["message"] |
26 |
| - out = "" |
27 | 18 | if old_class != current_class:
|
28 |
| - ndigits = int(math.log(i, 10) + 1) |
29 |
| - |
30 |
| - # 4 for : + space + # + space |
31 |
| - out += "-" * (len(name + msg) + 4 + ndigits) + "\n" |
32 |
| - out += "#{i} {name}: {msg}".format(i=i, name=name, msg=msg) |
33 |
| - skipped.append(out) |
34 |
| - i += 1 |
35 |
| - assert i - 1 == len(skipped) |
36 |
| - assert i - 1 == len(skipped) |
37 |
| - # assert len(skipped) == int(root.attrib['skip']) |
38 |
| - return "\n".join(skipped) |
39 |
| - |
40 |
| - |
41 |
| -def main(): |
42 |
| - test_files = ["test-data-single.xml", "test-data-multiple.xml", "test-data.xml"] |
43 |
| - |
44 |
| - print("SKIPPED TESTS:") |
45 |
| - for fn in test_files: |
46 |
| - if os.path.isfile(fn): |
47 |
| - print(parse_results(fn)) |
48 |
| - return 0 |
| 19 | + yield None |
| 20 | + yield { |
| 21 | + "class_name": current_class, |
| 22 | + "test_name": el.attrib["name"], |
| 23 | + "message": sk.attrib["message"], |
| 24 | + } |
49 | 25 |
|
50 | 26 |
|
51 | 27 | if __name__ == "__main__":
|
52 |
| - sys.exit(main()) |
| 28 | + print("SKIPPED TESTS:") |
| 29 | + i = 1 |
| 30 | + for file_type in ("-single", "-multiple", ""): |
| 31 | + for test_data in main("test-data{}.xml".format(file_type)): |
| 32 | + if test_data is None: |
| 33 | + print("-" * 80) |
| 34 | + else: |
| 35 | + print( |
| 36 | + "#{i} {class_name}.{test_name}: {message}".format( |
| 37 | + **dict(test_data, i=i) |
| 38 | + ) |
| 39 | + ) |
| 40 | + i += 1 |
0 commit comments