From 903f67d537482f4e9c8af14972518e477731d45b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 5 Dec 2026 11:51:48 +0000 Subject: [PATCH] Explain why OutcomeException derives from BaseException Closes #12235. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014GZsRGYP8wiAdqcDabFLTL --- changelog/12235.doc.rst | 1 + src/_pytest/outcomes.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/12235.doc.rst 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):