def create_xml_runner(test_pkg, test_name, results_file=None, is_rostest=False):
 test_name = os.path.basename(test_name)
 if (not results_file):
  results_file = xml_results_file(test_pkg, test_name, is_rostest)
 test_dir = os.path.abspath(os.path.dirname(results_file))
 if (not os.path.exists(test_dir)):
  try:
   makedirs_with_parent_perms(test_dir)
  except OSError as error:
   raise IOError(('cannot create test results directory [%s]: %s' % (test_dir, str(error))))
 elif os.path.isfile(test_dir):
  raise Exception(('ERROR: cannot run test suite, file is preventing creation of test dir: %s' % test_dir))
 print(('[ROSUNIT] Outputting test results to ' + results_file))
 outstream = open(results_file, 'w')
 outstream.write('<?xml version="1.0" encoding="utf-8"?>\n')
 return XMLTestRunner(stream=outstream)

def create_xml_runner ( test_pkg , test_name , results_file = None , is_rostest = False ) : test_name = os . path . basename ( test_name ) if ( not results_file ) : results_file = xml_results_file ( test_pkg , test_name , is_rostest ) test_dir = os . path . abspath ( os . path . dirname ( results_file ) ) if ( not os . path . exists ( test_dir ) ) : try : makedirs_with_parent_perms ( test_dir ) except OSError as error : raise IOError ( ( 'cannot create test results directory [%s]: %s' % ( test_dir , str ( error ) ) ) ) elif os . path . isfile ( test_dir ) : raise Exception ( ( 'ERROR: cannot run test suite, file is preventing creation of test dir: %s' % test_dir ) ) print ( ( '[ROSUNIT] Outputting test results to ' + results_file ) ) outstream = open ( results_file , 'w' ) outstream . write ( '<?xml version="1.0" encoding="utf-8"?>\n' ) return XMLTestRunner ( stream = outstream )
create the unittest test runner with xml output .