Replace MultipleFailures with ExceptionGroup on Python 3.11+#3191
Replace MultipleFailures with ExceptionGroup on Python 3.11+#3191Zac-HD wants to merge 1 commit intoHypothesisWorks:masterfrom
MultipleFailures with ExceptionGroup on Python 3.11+#3191Conversation
c5512fc to
d8e9868
Compare
d8e9868 to
0a4e2ae
Compare
|
Another future thing: (implemented in #3232) |
|
Per python/peps#2203, we should be using hypothesis/hypothesis-python/src/hypothesis/core.py Lines 488 to 501 in 09e5035 See also pytest-dev/pytest#9680 - a coherent ecosystem approach to this would be nice. |
|
The new (once a few questions are resolved around handling in Pytest, and how we print things like falsifying examples before PEP-678 |
|
Since we now have both an |
Closes #3175, related to #2192 (comment).
Example outputs on Python 3.9.8 and 3.11.0a3
Running
pytest test.pyprints, for respectively Python 3.9.8 and 3.11.0a3:_______________________________________________ test _______________________________________________ + Exception Group Traceback (most recent call last): | File "test.py", line 4, in test | def test(x): | | File "hypothesis/core.py", line 1202, in wrapped_test | raise the_error_hypothesis_found | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ExceptionGroup: Hypothesis found 2 distinct failures. | | Highest target score: 1 (label='') | +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "test.py", line 7, in test | assert x > 0 | ^^^^^^^^^^^^ | AssertionError: assert -1 > 0 | | Falsifying example: test( | x=-1, | ) +---------------- 2 ---------------- | Traceback (most recent call last): | File "test.py", line 6, in test | assert x < 0 | ^^^^^^^^^^^^ | AssertionError: assert 0 < 0 | | Falsifying example: test( | x=0, | ) +------------------------------------So use of the new
__note__approach does change the relative order of traceback and other information, but I don't think that's a big deal - we can reverse our own printing for consistency if it's important, because there are clear upstream reasons to display the__note__in relation to the exception object rather than the traceback.I'm ambivalent about using
__note__for singular errors, but if we want to that's left for future work in order to keep this diff small.