Skip to content
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

Except hook incompatibility with exceptiongroup backport #2427

Closed
vxgmichel opened this issue Sep 25, 2022 · 3 comments · Fixed by #2213
Closed

Except hook incompatibility with exceptiongroup backport #2427

vxgmichel opened this issue Sep 25, 2022 · 3 comments · Fixed by #2213

Comments

@vxgmichel
Copy link
Contributor

Since version 6.54.0, hypothesis uses exception notes (PEP 678) to show falsifying examples underneath the raised exception. With python < 3.11, this is done using a custom exception hook provided by exceptiongroup, a backport of PEP 654. The problem is that trio also uses a custom excepthook to manage multi-errors. In practice, this leads to the falsifying example not being displayed depending on the import order. Even worse, simply having pytest-trio installed causes the falsifying examples to disappear. Consider the following test:

from hypothesis import given
from hypothesis import strategies as st

@given(x=st.integers())
def test_notes(x):
    1/x

Without pytest-trio installed you would get:

    @given(x=st.integers())
    def test_notes(x):
>       1/x
E       ZeroDivisionError: division by zero
E       Falsifying example: test_notes(
E           x=0,
E       )

test_notes.py:7: ZeroDivisionError

And with pytest-trio installed:

    @given(x=st.integers())
    def test_notes(x):
>       1/x
E       ZeroDivisionError: division by zero

test_notes.py:7: ZeroDivisionError
@pquentin
Copy link
Member

pquentin commented Sep 25, 2022

@agronholm Do you think #2213 would help here?

@agronholm
Copy link
Contributor

Yup, since trio would no longer install its own hook. If you can manage to import exceptiongroup first, that would also work around this issue.

@pquentin
Copy link
Member

Thanks I edited the description of #2213 so that it closes this issue when merged. A Trio release will quickly follow anyway, as it's a long awaited feature and Python 3.11 will be release next month.

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 a pull request may close this issue.

3 participants