when i use --xunit-output i get UnicodeDecodeError in StringIO.getvalue #337

wants to merge 6 commits into


None yet

3 participants


because i have 1 unicode string in xml elements coming from

xunit_output.py 93: tc.setAttribute("name", u'| %s |' % u' | '.join(outline.values()))

I think the better way to go is to use unicode strings everywhere instead of converting every string in utf-8 . But this error can be solved by converting this line to utf-8 too.


Please send also automated tests that proof this bug.

The XUnit output feature was never implemented by myself, I keep getting pull requests that change the code to tweak "this" or "that", and it's absolutely ridiculous form the standpoint of a testing library.

I do not use the XUnit functionality myself, so if you care for this feature, please send a test that proofs your bug is actually a bug.


looking forward to this merge! thanks mike!

@gabrielfalcao gabrielfalcao and 1 other commented on an outdated diff Mar 27, 2013
@@ -194,3 +194,11 @@ def just_pass(step, *args):
assert_equals(1, len(called), "Function not called")
xunit_output.wrt_output = old
+@with_setup(prepare_stdout, registry.clear)
+def test_xunit_xml_output_with_no_errors():
+ 'Test xunit doc xml output'
+ runner = Runner(feature_name('xunit_unicode_and_bytestring_mixing'), enable_xunit=True)
+ runner.run()
gabrielfalcao Mar 27, 2013

now you can parse the output with lxml:

from sure import expect
from lxml import etree

root = etree.fromstring(content)

testcases = root.xpath('testcase')

mike-grayhat Mar 27, 2013

But i can't because exception will be raised before xunit_output.wrt_output method. To make an assertion I should create another method that will be called by output_xml (and can be replaced) and then it should call wrt_output. But then anyway i need to check that doc.toxml() do not raise an exception, and really i don't know how an assertion for it should be written.

pip install sure
def test_it_doesn_raise():
    def try_to_do_something():
        xunit_output.wrt_output ...


sure's documentation


@mike-grayhat thank you!


Just released version 0.2.16, thanks for this contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment