Skip to content

Strip characters that are invalid in XML from xunit output - #1095

Open
itzzdev09 wants to merge 1 commit into
getslash:developfrom
itzzdev09:xunit-strip-invalid-xml-chars
Open

itzzdev09 wants to merge 1 commit into
getslash:developfrom
itzzdev09:xunit-strip-invalid-xml-chars

Conversation

@itzzdev09

Copy link
Copy Markdown

Fixes #1091.

The xunit plugin wrote exception messages and tracebacks into the XML as is, so a test that raises AssertionError("Hello World! \x1B") produced a file that XML parsers (and CI tools such as Jenkins) reject.

Before writing the file, session_end now strips the characters that XML 1.0 does not allow (control characters other than tab, newline and carriage return, lone surrogates, U+FFFE/U+FFFF) from every element text and attribute value.

Added test_xunit_plugin_strips_characters_invalid_in_xml (a test that adds an error containing \x1b, then parses the xunit file). It fails without the change and passes with it. pytest tests/test_xunit_plugin.py: 85 passed, 4 skipped (the skips are existing does not run on windows tests); I ran this on Windows with Python 3.12 and did not run the rest of the suite or pylint.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xUnit Plugin writes invalid xml file, when escape characters are part of the exception

1 participant