@@ -94,15 +94,21 @@ def __init__(self, test_result, test_method, outcome=SUCCESS, err=None, subTest=
94
94
self .test_result = test_result
95
95
self .outcome = outcome
96
96
self .elapsed_time = 0
97
- self .err = err
97
+ if err :
98
+ if self .outcome != _TestInfo .SKIP :
99
+ self .test_exception_name = safe_unicode (err [0 ].__name__ )
100
+ self .test_exception_message = safe_unicode (err [1 ])
101
+ else :
102
+ self .test_exception_message = safe_unicode (err )
103
+
98
104
self .stdout = test_result ._stdout_data
99
105
self .stderr = test_result ._stderr_data
100
106
101
107
self .test_description = self .test_result .getDescription (test_method )
102
108
self .test_exception_info = (
103
109
'' if outcome in (self .SUCCESS , self .SKIP )
104
110
else self .test_result ._exc_info_to_string (
105
- self . err , test_method )
111
+ err , test_method )
106
112
)
107
113
108
114
self .test_name = testcase_name (test_method )
@@ -419,18 +425,18 @@ def _report_testcase(test_result, xml_testsuite, xml_document):
419
425
if test_result .outcome != test_result .SKIP :
420
426
failure .setAttribute (
421
427
'type' ,
422
- safe_unicode ( test_result .err [ 0 ]. __name__ )
428
+ test_result .test_exception_name
423
429
)
424
430
failure .setAttribute (
425
431
'message' ,
426
- safe_unicode ( test_result .err [ 1 ])
432
+ test_result .test_exception_message
427
433
)
428
434
error_info = safe_unicode (test_result .get_error_info ())
429
435
_XMLTestResult ._createCDATAsections (
430
436
xml_document , failure , error_info )
431
437
else :
432
438
failure .setAttribute ('type' , 'skip' )
433
- failure .setAttribute ('message' , safe_unicode ( test_result .err ) )
439
+ failure .setAttribute ('message' , test_result .test_exception_message )
434
440
435
441
_report_testcase = staticmethod (_report_testcase )
436
442
0 commit comments