def test_failure_junit_xml(test_name, message, stdout=None, class_name='Results', testcase_name='test_ran'):
 testsuite = ET.Element('testsuite')
 testsuite.set('tests', '1')
 testsuite.set('failures', '1')
 testsuite.set('time', '1')
 testsuite.set('errors', '0')
 testsuite.set('name', test_name)
 testcase = ET.SubElement(testsuite, 'testcase')
 testcase.set('name', testcase_name)
 testcase.set('status', 'run')
 testcase.set('time', '1')
 testcase.set('classname', class_name)
 failure = ET.SubElement(testcase, 'failure')
 failure.set('message', message)
 failure.set('type', '')
 if stdout:
  system_out = ET.SubElement(testsuite, 'system-out')
  system_out.text = cdata(filter_nonprintable_text(stdout))
 return ET.tostring(testsuite, encoding='utf-8', method='xml')

def test_failure_junit_xml ( test_name , message , stdout = None , class_name = 'Results' , testcase_name = 'test_ran' ) : testsuite = ET . Element ( 'testsuite' ) testsuite . set ( 'tests' , '1' ) testsuite . set ( 'failures' , '1' ) testsuite . set ( 'time' , '1' ) testsuite . set ( 'errors' , '0' ) testsuite . set ( 'name' , test_name ) testcase = ET . SubElement ( testsuite , 'testcase' ) testcase . set ( 'name' , testcase_name ) testcase . set ( 'status' , 'run' ) testcase . set ( 'time' , '1' ) testcase . set ( 'classname' , class_name ) failure = ET . SubElement ( testcase , 'failure' ) failure . set ( 'message' , message ) failure . set ( 'type' , '' ) if stdout : system_out = ET . SubElement ( testsuite , 'system-out' ) system_out . text = cdata ( filter_nonprintable_text ( stdout ) ) return ET . tostring ( testsuite , encoding = 'utf-8' , method = 'xml' )
generate junit xml file for a unary test suite where the test failed .