File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ def test_junitxml_properties(self):
305305 suite .properties = dict (key = 'value' )
306306 self ._test_xmlrunner (suite )
307307
308- def test_junitxml_xsd_validation (self ):
308+ def test_junitxml_xsd_validation_order (self ):
309309 suite = unittest .TestSuite ()
310310 suite .addTest (self .DummyTest ('test_fail' ))
311311 suite .addTest (self .DummyTest ('test_pass' ))
@@ -324,6 +324,20 @@ def test_junitxml_xsd_validation(self):
324324 i_testcase = output .index ('<testcase' .encode ('utf8' ))
325325 self .assertTrue (i_properties < i_testcase < i_system_out < i_system_err )
326326
327+ def test_junitxml_xsd_validation_empty_properties (self ):
328+ suite = unittest .TestSuite ()
329+ suite .addTest (self .DummyTest ('test_fail' ))
330+ suite .addTest (self .DummyTest ('test_pass' ))
331+ suite .properties = None
332+ outdir = BytesIO ()
333+ runner = xmlrunner .XMLTestRunner (
334+ stream = self .stream , output = outdir , verbosity = self .verbosity ,
335+ ** self .runner_kwargs )
336+ runner .run (suite )
337+ outdir .seek (0 )
338+ output = outdir .read ()
339+ self .assertNotIn ('<properties>' .encode ('utf8' ), output )
340+
327341 def test_xmlrunner_elapsed_times (self ):
328342 self .runner_kwargs ['elapsed_times' ] = False
329343 suite = unittest .TestSuite ()
Original file line number Diff line number Diff line change @@ -300,15 +300,14 @@ def _get_info_by_testcase(self):
300300 return tests_by_testcase
301301
302302 def _report_testsuite_properties (xml_testsuite , xml_document , properties ):
303- xml_properties = xml_document .createElement ('properties' )
304- xml_testsuite .appendChild (xml_properties )
305303 if properties :
304+ xml_properties = xml_document .createElement ('properties' )
305+ xml_testsuite .appendChild (xml_properties )
306306 for key , value in properties .items ():
307307 prop = xml_document .createElement ('property' )
308308 prop .setAttribute ('name' , str (key ))
309309 prop .setAttribute ('value' , str (value ))
310310 xml_properties .appendChild (prop )
311- return xml_properties
312311
313312 _report_testsuite_properties = staticmethod (_report_testsuite_properties )
314313
You can’t perform that action at this time.
0 commit comments