Skip to content

docs: clarify why OutcomeException inherits from BaseException - #15535

Closed
Alexander683 wants to merge 1 commit into
pytest-dev:mainfrom
Alexander683:docs/outcome-exception-baseexception
Closed

Alexander683 wants to merge 1 commit into
pytest-dev:mainfrom
Alexander683:docs/outcome-exception-baseexception

Conversation

@Alexander683

Copy link
Copy Markdown

Summary

Closes #12235.

Adds a brief clarifying note to the docstring of OutcomeException in src/_pytest/outcomes.py explaining that it intentionally inherits from BaseException rather than Exception so that broad except Exception: handlers in user code or tests do not accidentally swallow pytest outcomes (such as pytest.skip, pytest.fail, or pytest.xfail) without re-raising them.

Per CONTRIBUTING.rst, no changelog/ fragment is included since this only updates an internal docstring without changing documented behavior.

Testing / Verification

  • ruff check src/_pytest/outcomes.py (passed)
  • ruff format --check src/_pytest/outcomes.py (passed)
  • Verified src/_pytest/outcomes.py compiles and imports cleanly and that OutcomeException.__doc__ renders as expected.

AI attribution: Gemini (via Google Antigravity) assisted with reading the codebase, drafting the docstring note, and running local lint checks; I reviewed and verified the change.

Explain in OutcomeException's docstring that it inherits from BaseException rather than Exception so broad except Exception handlers do not accidentally swallow pytest outcomes without re-raising them.

Closes pytest-dev#12235

Assisted-by: Gemini (Google Antigravity)
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Closing on grounds of ai verbosity vomit 🤢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let OutcomeException inherit from Exception instead of BaseException

2 participants