question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Design discussion: how should we test for expected `ExceptionGroup`s?

See original GitHub issue

Python 3.11 has been released with the new ExceptionGroup type, and there’s a great backport too.

As people start to write code which can raise ExceptionGroups, there’s also going to be a corresponding need to test that they raised the expected group of exceptions, and that’s where this issue comes in: our existing APIs aren’t particularly helpful for this. For example, in the PR to use ExceptionGroups for Pytest teardown errors, I used with pytest.raises(...) to catch the group, but then had to manually unpack the structure and do isinstance() checks by hand.

I’d like to take our time and find the right API, rather than hurrying to any particular conclusion, and that should be based on a volume and diversity of experience that just doesn’t exist yet. This issue therefore exists to collect use-cases, design ideas, and discussion, until we’re confident that we can ship the right thing for the next decade.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Oct 27, 2022

To me that is something that needs a outside of pytest experiment that can iterate breaking

Its hard to get right, I’d like to use something like the ideas from dirty equals for it

0reactions
xaviergmailcommented, Nov 9, 2022

I am also looking forward to an official solution. In the meantime FWIW, I have pieced this together: https://gist.github.com/xaviergmail/90355b7611dcff27a6a0a60297666865

(In my case, I’m testing for exceptiongroups thrown by cattrs)

Read more comments on GitHub >

github_iconTop Results From Across the Web

JUnit Expected Exception Test: @Test(expected)
Exception testing is a special feature introduced in JUnit4. In this tutorial, you have learned how to test exception in JUnit using @test( ......
Read more >
Testing the wording of an Exception message
Second thing to do : write a test to check that the exception keeps the same text. Third thing to do : add...
Read more >
TestNG - Exception Test
You can test whether a code throws a desired exception or not. Here the expectedExceptions. ... The Complete TestNG & Automation Framework Design...
Read more >
junit - test for exception problem
I 'm trying to test if an exception is being thrown (when one is expected) I get this error (when I shouldn't): java.lang....
Read more >
How to Write Test Cases: The Ultimate Guide with Examples
This in-depth hands-on tutorial on How to Write Test Cases covers the details of what a Test Case is along with its standard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found