Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 03e5328

Browse files
committed
fix #217
1 parent 5086830 commit 03e5328

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎tests/testsuite.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ def test_error(self):
133133
def test_cdata_section(self):
134134
print('<![CDATA[content]]>')
135135

136+
def test_invalid_xml_chars_in_doc(self):
137+
"""
138+
Testing comments, -- is not allowed, or invalid xml 1.0 chars such as \x0c
139+
"""
140+
pass
141+
136142
def test_non_ascii_error(self):
137143
self.assertEqual(u"éçà", 42)
138144

@@ -617,6 +623,23 @@ def test_xmlrunner_cdata_section(self):
617623
suite.addTest(self.DummyTest('test_cdata_section'))
618624
self._test_xmlrunner(suite)
619625

626+
def test_xmlrunner_invalid_xml_chars_in_doc(self):
627+
suite = unittest.TestSuite()
628+
suite.addTest(self.DummyTest('test_invalid_xml_chars_in_doc'))
629+
outdir = BytesIO()
630+
runner = xmlrunner.XMLTestRunner(
631+
stream=self.stream, output=outdir, verbosity=self.verbosity,
632+
**self.runner_kwargs)
633+
runner.run(suite)
634+
outdir.seek(0)
635+
output = outdir.read()
636+
# Finally check if we have a valid XML document or not.
637+
try:
638+
minidom.parseString(output)
639+
except Exception as e: # pragma: no cover
640+
# note: we could remove the try/except, but it's more crude.
641+
self.fail(e)
642+
620643
def test_xmlrunner_outsuffix(self):
621644
self.runner_kwargs['outsuffix'] = '.somesuffix'
622645
suite = unittest.TestSuite()

‎xmlrunner/result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def _report_testcase(test_result, xml_testsuite, xml_document):
579579
comment = str(test_result.doc)
580580
# The use of '--' is forbidden in XML comments
581581
comment = comment.replace('--', '&#45;&#45;')
582-
testcase.appendChild(xml_document.createComment(comment))
582+
testcase.appendChild(xml_document.createComment(safe_unicode(comment)))
583583

584584
result_elem_name = test_result.OUTCOME_ELEMENTS[test_result.outcome]
585585

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /