INNER CODE UNIT · Python
attribute_hook_failures
scality/Zenko · .github/scripts/merge-junit-reports.py:29
def attribute_hook_failures(suite):
"""Re-attribute mocha hook-failure testcases to their owning test.
The flaky-test detection in action-junit-report pairs a failure with a
later pass by (name, classname, file). A hook-failure entry can never have
a passing counterpart with the same key, so a single hook flake would fail
the build on every retry. mocha names a failed hook after the test it ran
for, so rewriting the entry to that test's name/classname lets a retried
pass cancel it out. A suite-level hook with no test to attach to keeps a
bare '"... hook"' title and is left as-is (does not happen in practice).
"""
for tc in suite.findall('testcase'):
for attr in ('name', 'classname'):
value = tc.get(attr)
if value is not None:
tc.set(attr, HOOK_FOR_RE.sub(r'\1', value))
def merge_testsuites(testsuites_list):