INNER CODE UNIT · Python
write_report
apache/ozone · dev-support/ci/test_junit_summary.py:46
def write_report(self, tmp, relpath, content=SAMPLE_XML):
path = os.path.join(tmp, relpath)
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
return path
def test_classification(self):
with tempfile.TemporaryDirectory() as tmp:
path = self.write_report(tmp, "hadoop-hdds/common/target/surefire-reports/TEST-x.xml")
cases = junit_summary.parse_report(path)
by_name = {c.test_name: c for c in cases}
self.assertEqual(len(cases), 4)
self.assertEqual(by_name["testPasses"].status, "passed")
self.assertEqual(by_name["testFails"].status, "failed")
self.assertEqual(by_name["testFlaky"].status, "flaky")
self.assertEqual(by_name["testSkipped"].status, "skipped")
self.assertEqual(by_name["testFails"].class_name, "org.apache.hadoop.ozone.TestExample")