Add karva.raises context manager for asserting exceptions#430
Merged
MatthewMckee4 merged 1 commit intomainfrom Feb 7, 2026
Merged
Add karva.raises context manager for asserting exceptions#430MatthewMckee4 merged 1 commit intomainfrom
karva.raises context manager for asserting exceptions#430MatthewMckee4 merged 1 commit intomainfrom
Conversation
Provides a native `pytest.raises`-equivalent so users can assert that code raises a specific exception without depending on pytest.
Project Diff ResultsNo changes between this PR and main. |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
2 tasks
MatthewMckee4
added a commit
that referenced
this pull request
Feb 7, 2026
## Summary - Add a `## Raises` section to `docs/usage/functions.md` documenting the `karva.raises` context manager added in #430 - Covers basic usage, the `match` parameter for regex matching, accessing exception info, and pytest compatibility ## Test plan - [x] `prek run -a` passes - [ ] Verify docs render correctly on the docs site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
karva.raises(expected_exception, *, match=None)context manager as a nativepytest.raises-equivalentmatchparameter, andExceptionInfoaccess (type,value,tb)FailErrorfor "DID NOT RAISE" and pattern mismatch failures; propagates non-matching exception typesTest plan
matchparameter that matches passesmatchparameter that doesn't match failsExceptionInfofields accessible after blockjust test)prek run -a)Closes #429
🤖 Generated with Claude Code