Skip to content

Except hook incompatibility with exceptiongroup backport #2427

Closed
@vxgmichel

Description

@vxgmichel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions