gabrielfalcao/lettuce — pull request #302 by arnihermann (2012-12-04 09:53:15+00:00)
Title: xunit output doesn't handle unicode strings

xunit output throws an exception when some of the tracebacks have unicode strings in them.

The proposed fix interprets the traceback string as utf8 before writing it to a `minidom` attribute.

Example of failure:

```
Traceback (most recent call last):
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/registry.py", line 88, in call_hook
callback(*args, **kw)
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/plugins/xunit_output.py", line 105, in output_xml
wrt_output(output_filename, doc.toxml())
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py", line 45, in toxml
return self.toprettyxml("", "", encoding)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py", line 60, in toprettyxml
return writer.getvalue()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/StringIO.py", line 271, in getvalue
self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 314: ordinal not in range(128)

Traceback (most recent call last):
File "/Users/arnihermann/github/ja-neo/bin/lettuce", line 9, in
load_entry_point('lettuce==0.2.10', 'console_scripts', 'lettuce')()
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/bin.py", line 88, in main
result = runner.run()
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/__init__.py", line 172, in run
call_hook('after', 'all', total)
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/registry.py", line 88, in call_hook
callback(*args, **kw)
File "/Users/arnihermann/github/ja-neo/src/lettuce/lettuce/plugins/xunit_output.py", line 105, in output_xml
wrt_output(output_filename, doc.toxml())
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py", line 45, in toxml
return self.toprettyxml("", "", encoding)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py", line 60, in toprettyxml
return writer.getvalue()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/StringIO.py", line 271, in getvalue
self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 314: ordinal not in range(128)

```