def parse_fixture_error(root_dir, lines):
    result = []
    file_location = None
    stderr_call = re.compile("-{2,} Captured stderr setup -{2,}")

    lines_ = iter(lines)
    for line in lines_:
        result.append(line)
        # File location  can come first if the fixture error is a 'fixture not
        # found' error type.
        location = match_fixture_not_found_file_location(line)
        if location:
            file_location = location
            continue
        location = match_file_location(line)
        if location:
            file_location = location
            continue
        error = match_fixture_not_found_error(line)
        if error:
            result.append(
                make_error_format(
                    file_location.get('file_path', ""),
                    file_location.get('line_no', ""),
                    error['error'],
                ),
            )
            break
        error = match_fixture_scope_mismatch(line)
        if error:
            line = next(lines_)
            result.append(line)
            location = match_file_location(line)
            if location:
                file_path = location['file_path']
                if root_dir:
                    file_path = os.path.join(root_dir, file_path)
                result.append(
                    make_error_format(
                        file_path,
                        location['line_no'],
                        error,
                    ),
                )
            break
        if stderr_call.match(line):
            result.extend(parse_traceback(lines_))
            break

    # Consume left over prior returning
    result.extend(lines_)
    return result
Parse *pytest* output of a *fixture error* section.
dataset/ETHPy150Open okcompute/vim-python-tests-runner/compiler/runners/pytest.py/parse_fixture_error