diff --git a/changelog/12235.doc.rst b/changelog/12235.doc.rst new file mode 100644 index 00000000000..32488370edc --- /dev/null +++ b/changelog/12235.doc.rst @@ -0,0 +1 @@ +Documented why ``OutcomeException`` derives from ``BaseException``. diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 257b95cf585..da18a07878a 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -11,8 +11,11 @@ class OutcomeException(BaseException): - """OutcomeException and its subclass instances indicate and contain info - about test and collection outcomes.""" + """Signals a test or collection outcome (skip, fail, xfail, ...). + + Derives from BaseException so ``except Exception:`` won't swallow it. + Catch it only to re-raise. + """ def __init__(self, msg: str | None = None, pytrace: bool = True) -> None: if msg is not None and not isinstance(msg, str):