Skip to content

Commit 04b4d0e

Browse files
committed
Report only first bug on Pytest
1 parent 6ed60ac commit 04b4d0e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

hypothesis-python/src/_hypothesis_pytestplugin.py

+7
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ def pytest_configure(config):
178178
pass
179179
core.global_force_seed = seed
180180

181+
core.pytest_shows_exceptiongroups = (
182+
sys.version_info[:2] >= (3, 11)
183+
## See https://github.com/pytest-dev/pytest/issues/9159
184+
# or pytest_version >= (7, 2) # TODO: fill in correct version here
185+
or config.getoption("tbstyle", "auto") == "native"
186+
)
187+
181188
@pytest.hookimpl(hookwrapper=True)
182189
def pytest_runtest_call(item):
183190
__tracebackhide__ = True

hypothesis-python/src/hypothesis/core.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126

127127

128128
running_under_pytest = False
129+
pytest_shows_exceptiongroups = True
129130
global_force_seed = None
130131
_hypothesis_global_random = None
131132

@@ -436,7 +437,7 @@ def execute_explicit_examples(state, wrapped_test, arguments, kwargs, original_s
436437
err = new
437438

438439
yield (fragments_reported, err)
439-
if state.settings.report_multiple_bugs:
440+
if state.settings.report_multiple_bugs and pytest_shows_exceptiongroups:
440441
continue
441442
break
442443
finally:
@@ -840,7 +841,7 @@ def run_engine(self):
840841

841842
if not self.falsifying_examples:
842843
return
843-
elif not self.settings.report_multiple_bugs:
844+
elif not (self.settings.report_multiple_bugs and pytest_shows_exceptiongroups):
844845
# Pretend that we only found one failure, by discarding the others.
845846
del self.falsifying_examples[:-1]
846847

0 commit comments

Comments
 (0)