|
25 |
def begin_test(self, case, prefix=''): |
25 |
def begin_test(self, case, prefix=''): |
26 |
"""Called before each test.""" |
26 |
"""Called before each test.""" |
27 |
super(Junit, self).begin_test(case, prefix) |
27 |
super(Junit, self).begin_test(case, prefix) |
28 |
self.now = datetime.today() |
28 |
self.now = datetime.today().replace(microsecond=0) |
29 |
|
29 |
|
30 |
def end_test(self, result): |
30 |
def end_test(self, result): |
31 |
"""Called after each test.""" |
31 |
"""Called after each test.""" |
|
40 |
errors = 1 |
40 |
errors = 1 |
41 |
else: |
41 |
else: |
42 |
errors = 1 |
42 |
errors = 1 |
|
|
43 |
classname = encode(result.case.uid.replace("/", ".")) |
43 |
|
44 |
|
44 |
filename = os.path.join(self.outdir, '%s.xml' % (result.case.uid,)) |
45 |
filename = os.path.join(self.outdir, '%s.xml' % (result.case.uid,)) |
45 |
dirname = os.path.dirname(filename) |
46 |
dirname = os.path.dirname(filename) |
|
53 |
xml = XMLGenerator(f_report, encoding='utf-8') |
54 |
xml = XMLGenerator(f_report, encoding='utf-8') |
54 |
xml.startDocument() |
55 |
xml.startDocument() |
55 |
xml.startElement('testsuite', { |
56 |
xml.startElement('testsuite', { |
56 |
'name': encode(result.case.description or result.case.uid), |
57 |
'name': classname, |
57 |
'tests': '%d' % (1,), |
58 |
'tests': '%d' % (1,), |
58 |
'failures': '%d' % (failures,), |
59 |
'failures': '%d' % (failures,), |
59 |
'errors': '%d' % (errors,), |
60 |
'errors': '%d' % (errors,), |
|
62 |
'skipped': '%d' % (skipped,), |
63 |
'skipped': '%d' % (skipped,), |
63 |
'timestamp': self.now.isoformat(), |
64 |
'timestamp': self.now.isoformat(), |
64 |
'hostname': os.uname()[1], |
65 |
'hostname': os.uname()[1], |
65 |
'id': result.case.uid, |
|
|
66 |
'package': self.section, |
67 |
}) |
66 |
}) |
68 |
|
67 |
|
69 |
xml.startElement('properties', {}) |
68 |
xml.startElement('properties', {}) |
|
87 |
'value': '%s' % (result.environment.ucs_version,), |
86 |
'value': '%s' % (result.environment.ucs_version,), |
88 |
}) |
87 |
}) |
89 |
xml.endElement('property') |
88 |
xml.endElement('property') |
|
|
89 |
if result.case.description: |
90 |
xml.startElement('property', { |
91 |
'name': 'description', |
92 |
'value': encode(result.case.description or result.case.uid), |
93 |
}) |
94 |
xml.endElement('property') |
90 |
xml.endElement('properties') |
95 |
xml.endElement('properties') |
91 |
|
96 |
|
92 |
xml.startElement('testcase', { |
97 |
xml.startElement('testcase', { |
93 |
'name': encode(result.case.description or result.case.uid), |
98 |
'name': 'test', |
94 |
#'assertions': '%d' % (0,), |
99 |
#'assertions': '%d' % (0,), |
95 |
'time': '%0.3f' % (result.duration / 1000.0,), |
100 |
'time': '%0.3f' % (result.duration / 1000.0,), |
96 |
'classname': result.case.uid, |
101 |
'classname': classname, |
97 |
#'status': '???', |
102 |
#'status': '???', |
98 |
}) |
103 |
}) |
99 |
|
104 |
|