Commit a2a0daa
Fix crash when exceptions contain unicode in buffered output (#199)
When `xmlrunner.XMLTestRunner` is run in buffered mode,
`sys.stdout` points to StringIO instance. It has `encoding`
attribute, but it is set to `None` which causes a crash during
the test run in Python 2:
Traceback (most recent call last):
File "/home/miika/apps/unittest-xml-reporting/tests/testsuite.py", line 376, in test_xmlrunner_non_ascii_failures_buffered_output
self._xmlrunner_non_ascii_failures(buffer=True)
File "/home/miika/apps/unittest-xml-reporting/tests/testsuite.py", line 398, in _xmlrunner_non_ascii_failures
runner.run(suite)
File "/home/miika/apps/unittest-xml-reporting/xmlrunner/runner.py", line 70, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/case.py", line 393, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/case.py", line 333, in run
result.addFailure(self, sys.exc_info())
File "/usr/lib/python2.7/unittest/result.py", line 19, in inner
return method(self, *args, **kw)
File "/home/miika/apps/unittest-xml-reporting/xmlrunner/result.py", line 344, in addFailure
self, test, self.infoclass.FAILURE, err)
File "/home/miika/apps/unittest-xml-reporting/xmlrunner/result.py", line 163, in __init__
err, test_method)
File "/home/miika/apps/unittest-xml-reporting/xmlrunner/result.py", line 703, in _exc_info_to_string
line = line.encode(encoding)
TypeError: encode() argument 1 must be string, not None1 parent 0fde905 commit a2a0daa
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
394 | 400 | | |
395 | 401 | | |
396 | | - | |
| 402 | + | |
397 | 403 | | |
398 | 404 | | |
399 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
697 | 700 | | |
698 | 701 | | |
699 | 702 | | |
| |||
0 commit comments