-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept generic ExceptionGroups for raises (#13134)
* Accept generic ExceptionGroups for raises Closes #13115 * Fix review suggestions * Add extra test, changelog improvement * Minor suggested refactor of if clause (review comment) --------- Co-authored-by: Bruno Oliveira <[email protected]>
- Loading branch information
1 parent
2f1c143
commit ecff0ba
Showing
4 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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,8 @@ | ||
Allows supplying ``ExceptionGroup[Exception]`` and ``BaseExceptionGroup[BaseException]`` to ``pytest.raises`` to keep full typing on :class:`ExceptionInfo <pytest.ExceptionInfo>`: | ||
|
||
.. code-block:: python | ||
with pytest.raises(ExceptionGroup[Exception]) as exc_info: | ||
some_function() | ||
Parametrizing with other exception types remains an error - we do not check the types of child exceptions and thus do not permit code that might look like we do. |
This file contains 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 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