Repository: pytest-dev/pytest
File: src/_pytest/reports.py (Python)

Code before:
    stream = StringIO()
    pprint("-" * 100, stream=stream)
    pprint(f"INTERNALERROR: Unknown entry type returned: {type_name}", stream=stream)
    pprint(f"report_name: {report_class}", stream=stream)
    pprint(reportdict, stream=stream)
    pprint(f"Please report this bug at {url}", stream=stream)
    pprint("-" * 100, stream=stream)
    raise RuntimeError(stream.getvalue())


def _format_failed_longrepr(
    item: Item, call: CallInfo[None], excinfo: ExceptionInfo[BaseException]
):
    if call.when == "call":
        longrepr = item.repr_failure(excinfo)
    else:  # exception in setup or teardown
        longrepr = item._repr_failure_py(
            excinfo, style=item.config.getoption("tbstyle", "auto")
        )
    return longrepr


def _format_exception_group_all_skipped_longrepr(
    item: Item,
    excinfo: ExceptionInfo[BaseException],
    exceptions: list[Skipped],
) -> tuple[str, int, str]:
    r = excinfo._getreprcrash()
    assert r is not None, (
        "There should always be a traceback entry for skipping a test."
    )
    if any(getattr(skip, "_use_item_location", False) for skip in exceptions):
        path, line = item.reportinfo()[:2]
        assert line is not None
        loc = (os.fspath(path), line + 1)
        default_msg = "skipped"
        # longrepr = (*loc, r.message)
    else:
        assert r is not None
        loc = (str(r.path), r.lineno)
        default_msg = r.message

    # reason(s): order-preserving de-dupe, same fields as single-skip
    msgs: list[str] = []
    for exception in exceptions:
        m = exception.msg or exception.args[0]
        if m and m not in msgs:
            msgs.append(m)

    reason = "; ".join(msgs) if msgs else default_msg
    longrepr = (*loc, reason)

Review comment (suggestion):
Since `exceptions` is not modified by this function, prefer `Sequence[Skipped]` over `list[Skipped]`.

Code after:
    pprint("-" * 100, stream=stream)
    pprint(f"INTERNALERROR: Unknown entry type returned: {type_name}", stream=stream)
    pprint(f"report_name: {report_class}", stream=stream)
    pprint(reportdict, stream=stream)
    pprint(f"Please report this bug at {url}", stream=stream)
    pprint("-" * 100, stream=stream)
    raise RuntimeError(stream.getvalue())


def _format_failed_longrepr(
    item: Item, call: CallInfo[None], excinfo: ExceptionInfo[BaseException]
):
    if call.when == "call":
        longrepr = item.repr_failure(excinfo)
    else:
        # Exception in setup or teardown.
        longrepr = item._repr_failure_py(
            excinfo, style=item.config.getoption("tbstyle", "auto")
        )
    return longrepr


def _format_exception_group_all_skipped_longrepr(
    item: Item,
    excinfo: ExceptionInfo[BaseExceptionGroup[BaseException | BaseExceptionGroup]],
) -> tuple[str, int, str]:
    r = excinfo._getreprcrash()
    assert r is not None, (
        "There should always be a traceback entry for skipping a test."
    )
    if all(
        getattr(skip, "_use_item_location", False) for skip in excinfo.value.exceptions
    ):
        path, line = item.reportinfo()[:2]
        assert line is not None
        loc = (os.fspath(path), line + 1)
        default_msg = "skipped"
    else:
        loc = (str(r.path), r.lineno)
        default_msg = r.message

    # Get all unique skip messages.
    msgs: list[str] = []
    for exception in excinfo.value.exceptions:
        m = getattr(exception, "msg", None) or (
            exception.args[0] if exception.args else None
        )
        if m and m not in msgs:
            msgs.append(m)

    reason = "; ".join(msgs) if msgs else default_msg