def parse_xunit_tsuite(ts, skip_attr_name='skip'):
  tcs = ts.getElementsByTagName('testcase')
  testcases = []
  for tc in tcs:
    failure = None
    failureNode = None
    failures = tc.getElementsByTagName('failure')
    if len(failures) > 0:
      failureNode = failures[0]
    errors = tc.getElementsByTagName('error')
    if len(errors) > 0:
      failureNode = errors[0]
    if failureNode != None:
      failure = Failure(attr_val(failureNode, 'type'), failureNode.childNodes[0].data)
    testcases.append(TestCase(attr_val(tc, 'classname'), attr_val(tc, 'name'), failure))
  skipped = 0
  if skip_attr_name != None:
    skipped = int(attr_val(ts, skip_attr_name))
  return XunitTestSuite(attr_val(ts, 'name'), int(attr_val(ts, 'tests')), int(attr_val(ts, 'errors')), int(attr_val(ts, 'failures')), skipped, testcases)
dataset/ETHPy150Open lacostej/nosyd/nosyd/xunit.py/parse_xunit_tsuite/original