-
-
Notifications
You must be signed in to change notification settings - Fork 368
Add RaisesGroup, a helper for catching ExceptionGroups in tests #2898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
30a7a40
Add RaisesGroup, a helper for catching ExceptionGroups in tests
jakkdl 0d08e19
fix some CI test errors, now only some grumpy export tests left
jakkdl 8f1e221
clarify mixed loose test
jakkdl f7ec079
rename variable to fit new class name
jakkdl c7c6264
ignore RaisesGroup in test_exports for now
jakkdl 49af03d
fix test_export fail
jakkdl 3f63030
fix pyright --verifytypes errors
jakkdl 3adc49a
un-unittest the tests
jakkdl cd9d3a5
add test for _ExceptionInfo (and fix it)
jakkdl e9688be
rewrite not to use any in assert, since codecov doesn't like it
jakkdl 97fb79b
* Split out type tests
jakkdl 5f0298b
Merge remote-tracking branch 'origin/master' into raisesgroup
jakkdl faaebf5
rewrite another test to use RaisesGroup
jakkdl 22d8b5a
add new classes to docs
jakkdl 32d079a
Merge remote-tracking branch 'origin/master' into raisesgroup
jakkdl 43a51b6
Fix ruff issues
CoolCat467 3cc15e6
add fix for TracebackType
jakkdl efbccbc
cover __str__ of Matcher with no type specified
jakkdl 1261dc1
properly "fix" sphinx+TracebackType
jakkdl ccdb79d
add newsfragment
jakkdl 7956848
fix url in newsfragment
jakkdl d6d7595
Merge branch 'master' into raisesgroup
CoolCat467 4990a7d
Add overloads to Matcher() to precisely check init parameters
TeamSpen210 86287a5
Pre-compile strings passed to Matcher(), but unwrap in __str__
TeamSpen210 663c12b
update comment, add pyright: ignore
jakkdl 148df67
fix formatting, move matcher_tostring test to test_testing_raisesgroup
jakkdl c8f7983
add docstrings
jakkdl 9b66187
Apply suggestions from code review
jakkdl d020655
add comments
jakkdl 957b4fd
switch to tell type checkers that we always use _ExceptionInfo. Add n…
jakkdl 614f85a
fix broken test
jakkdl 80b7031
fix newsfragment quoting of pytest
jakkdl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
New helper classes: :class:`~.testing.RaisesGroup` and :class:`~.testing.Matcher`. | ||
|
||
In preparation for changing the default of ``strict_exception_groups`` to `True`, we're introducing a set of helper classes that can be used in place of `pytest.raises <https://docs.pytest.org/en/stable/reference/reference.html#pytest.raises>`_ in tests, to check for an expected `ExceptionGroup`. | ||
These are provisional, and only planned to be supplied until there's a good solution in ``pytest``. See https://github.com/pytest-dev/pytest/issues/11538 |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes should have docstrings aimed at explaining their use to end-users, if we're exposing them publicly.
I'd also prefer to mark this as a provisional interface, and note that we hope for it to be obsoleted by upstream work in pytest itself someday soon. (note: carefully noncommital about what happens or when)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote extensive docstrings... on a computer I'm currently 500km away from, and forgot to push. So I'll add them once back the 30th of december.
But good call to explicitly mark them as provisional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a bump about this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added them, and a note about them being provisional in the newsfragment.