runtime
482 / 500
question 482 Application Delivery · easy

Read unittest's summary line

The CI dashboard reads the last line of each test run, such as FAILED (failures=1, errors=2) or OK (skipped=3), and shows the counts. It shows 0 errors for every red build and crashes on runs with skipped tests. Fix summary_counts so it returns the right counts for every form of the line.

Read and diagnose: this can't run in the browser, so you'll read real code and output and answer questions about it.

Functionsummary_counts(line)
LineOK, OK (skipped=1), FAILED (failures=2), FAILED (failures=1, errors=2, skipped=3) …
Returns{"ok": bool, "failures": n, "errors": n, "skipped": n}, zero for any count the line doesn't mention
Examples
callsummary_counts('FAILED (failures=1, errors=2)')returns{'ok': False, 'failures': 1, 'errors': 2, 'skipped': 0}
callsummary_counts('OK')returns{'ok': True, 'failures': 0, 'errors': 0, 'skipped': 0}
callsummary_counts('FAILED (failures=3)')returns{'ok': False, 'failures': 3, 'errors': 0, 'skipped': 0}

Loading your progress…

Read unittest's summary line — Python practice · Runtime