def parse_failure(lines):
    lines_ = iter(lines)
    result = [next(lines_)]
    location = {'file_path': 'Unknown', 'line_no': 'Unknown'}
    stderr_call = re.compile("-{2,} Captured stderr call -{2,}")

    for line in lines_:
        result.append(line)
        failure = match_failure(line)
        if failure and location['file_path'] != 'Unknown':
            result.append(
                make_error_format(
                    location['file_path'],
                    location['line_no'],
                    failure,
                ),
            )
            break
        else:
            file_location = match_file_location(line)
            if file_location:
                location = file_location

    for line in lines_:
        result.append(line)
        if stderr_call.match(line):
            result.extend(parse_traceback(lines_))
            break

    result.extend(lines_)
    if len(lines) == len(result):
        # Nothing was found! This is probably because of
        result.append(
            make_error_format(
                location['file_path'],
                location['line_no'],
                "An error was found but could not be parsed. This is probably "
                "a missing error pattern. Please post an issue on GitHub.",
            ),
        )

    return result
Test script on Windows in a new console window. Take a screenshot to verify colors work.
dataset/ETHPy150Open okcompute/vim-python-tests-runner/compiler/runners/pytest.py/parse_failure--crossover with--dataset/ETHPy150Open Robpol86/colorclass/tests/test_example.py/test_windows_screenshot