@@ -133,6 +133,12 @@ def test_error(self):
133
133
def test_cdata_section (self ):
134
134
print ('<![CDATA[content]]>' )
135
135
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
+
136
142
def test_non_ascii_error (self ):
137
143
self .assertEqual (u"éçà" , 42 )
138
144
@@ -617,6 +623,23 @@ def test_xmlrunner_cdata_section(self):
617
623
suite .addTest (self .DummyTest ('test_cdata_section' ))
618
624
self ._test_xmlrunner (suite )
619
625
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
+
620
643
def test_xmlrunner_outsuffix (self ):
621
644
self .runner_kwargs ['outsuffix' ] = '.somesuffix'
622
645
suite = unittest .TestSuite ()
0 commit comments