Skip to content

stdout and stderr double-encoded in junitxml #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Aug 15, 2012 · 3 comments
Closed

stdout and stderr double-encoded in junitxml #178

pytestbot opened this issue Aug 15, 2012 · 3 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)


I'm finding that the junit XML generated by pytest 2.2.4 gets double-encoded output. For example, here's a snippet from one run:

<failure>... Error in parsing

gryphon/models/qsl.py:63: QSLError</failure><system-err>Message 1
{&amp;apos;exception&amp;apos;: [&amp;apos;ParseError: Both inline and named res
ponse lists were used for question lookahead\n&amp;apos;],
 &amp;apos;message&amp;apos;: [&amp;apos;ParseError: Both inline and named respo
nse lists were used for question lookahead\n&amp;apos;],
 &amp;apos;status&amp;apos;: 500,
...

The stderr stream for that looks something like:

Message 1
{'exception': ['ParseError: Both inline and named response lists were used for question lookahead\n'],
 'message': ['ParseError: Both inline and named response lists wer eused for the queston lookahead\n'],
 'status': 500,

Notice that the tickmarks are being escaped for XML (to ') and then again the ampersand is getting escaped to &apos;.


@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


After a bit of investigation, it appears the problem is due to encoding in two places. When the content is added to the tag, in LogXML.append_failure, bin_xml_escape is called, which converts ' to &apos;. Then, when the tag is rendered, it calls py._xmlgen.escape.

Removing the call to bin_xml_escape helps, and addresses the issues I've encountered, but almost certainly breaks whatever was intended by bin_xml_escape (specifically escaping other characters).

Note that the test in the pull request doesn't pass by removing bin_xml_escape because the apostrophes aren't escaped (probably because they don't need to be in XML text), so the test may need to be updated.

Please let me know if there's more I can do to expedite a fix for this issue.

Regards - Jason

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


i think i introduced that bug when fixing errors about incorrectly handling some binary data

im under the impression that returning a py.xml.raw might be needed

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


fix issue #178 and extend the failure escape test

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant