def parse_sections(lines):
    section_types = {
        'session': re.compile(r"={2,} test session starts ={2,}"),
        'errors': re.compile(r"={2,} ERRORS ={2,}"),
        'failures': re.compile(r"={2,} FAILURES ={2,}"),
        'summary': re.compile(r"={2,} .* failed in .* seconds ={2,}"),
    }
    sections = {}
    for lines in group_lines(lines, r"={2,} .* ={2,}"):
        for section_type, regex in section_types.iteritems():
            if regex.match(lines[0]):
                sections[section_type] = lines
                break
    return sections
Parse pytest output and group lines per section (Errors, failures,
dataset/ETHPy150Open okcompute/vim-python-tests-runner/compiler/runners/pytest.py/parse_sections