Skip to content

Commit

Permalink
Report only first bug on Pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jul 27, 2022
1 parent 6ed60ac commit 04b4d0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions hypothesis-python/src/_hypothesis_pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ def pytest_configure(config):
pass
core.global_force_seed = seed

core.pytest_shows_exceptiongroups = (
sys.version_info[:2] >= (3, 11)
## See https://github.com/pytest-dev/pytest/issues/9159
# or pytest_version >= (7, 2) # TODO: fill in correct version here
or config.getoption("tbstyle", "auto") == "native"
)

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(item):
__tracebackhide__ = True
Expand Down
5 changes: 3 additions & 2 deletions hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@


running_under_pytest = False
pytest_shows_exceptiongroups = True
global_force_seed = None
_hypothesis_global_random = None

Expand Down Expand Up @@ -436,7 +437,7 @@ def execute_explicit_examples(state, wrapped_test, arguments, kwargs, original_s
err = new

yield (fragments_reported, err)
if state.settings.report_multiple_bugs:
if state.settings.report_multiple_bugs and pytest_shows_exceptiongroups:
continue
break
finally:
Expand Down Expand Up @@ -840,7 +841,7 @@ def run_engine(self):

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

Expand Down

0 comments on commit 04b4d0e

Please sign in to comment.