INNER CODE UNIT · Python
test_message_keeps_junit5_tail_when_custom_message_floods
apache/ozone · dev-support/ci/test_junit_summary.py:75
def test_message_keeps_junit5_tail_when_custom_message_floods(self):
# assertEquals(expected, actual, message) renders as "<custom message> ==> expected: ... but was: ...";
# some tests embed whole logs as the custom message, which would push the tail past the truncation limit
flood = "log line " * 100
xml = ('<testsuite><testcase name="t" classname="C" time="1">'
'<failure message="client log: %s ==> expected: <1> but was: <2>"/>'
'</testcase></testsuite>' % flood)
with tempfile.TemporaryDirectory() as tmp:
path = self.write_report(tmp, "m/target/surefire-reports/TEST-x.xml", content=xml)
cases = junit_summary.parse_report(path)
self.assertEqual(cases[0].message, "expected: <1> but was: <2>")
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