INNER CODE UNIT · Python
test_message_junit5_tail_edge_cases
apache/ozone · dev-support/ci/test_junit_summary.py:87
def test_message_junit5_tail_edge_cases(self):
fromstring = junit_summary.ET.fromstring
# short custom messages are meaningful and kept in full
elem = fromstring('<failure message="wrong count ==> expected: <1> but was: <2>"/>')
self.assertEqual(junit_summary.clean_message(elem), "wrong count ==> expected: <1> but was: <2>")
# assertion values containing " ==> " must not corrupt the tail
long_context = "x" * 400
elem = fromstring('<failure message="%s ==> expected: <a ==> b> but was: <c>"/>' % long_context)
self.assertEqual(junit_summary.clean_message(elem), "expected: <a ==> b> but was: <c>")
# long messages with " ==> " but no assertion framing fall back to head truncation
elem = fromstring('<failure message="pipeline A ==> B failed %s"/>' % long_context)
self.assertTrue(junit_summary.clean_message(elem).startswith("pipeline A ==> B failed"))
def test_module_name_from_path(self):
# normal surefire layout: module is the dir above target/
self.assertEqual(junit_summary.module_name("hadoop-hdds/common/target/surefire-reports/TEST-a.xml"), "common")
# layout after _mvn_unit_report.sh moves a failed test's XML under target/<check>/<module-path>/
self.assertEqual(junit_summary.module_name("target/unit/hadoop-hdds/common/TEST-a.xml"), "common")