Skip to content

Commit

Permalink
Remove import for _pytest.runner.call_runtest_hook
Browse files Browse the repository at this point in the history
Fixes incompatibility with pytest == 8.1.0 by internalizing call_runtest_hook function.
  • Loading branch information
jonathan-eq committed Mar 5, 2024
1 parent 69c297e commit 493996e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion flaky/flaky_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,23 @@ def call_and_report(self, item, when, log=True, **kwds):
:type log:
`bool`
"""
call = runner.call_runtest_hook(item, when, **kwds)
def _call_runtest_hook(item, when, **kwds):
if when == "setup":
ihook = item.ihook.pytest_runtest_setup
elif when == "call":
ihook = item.ihook.pytest_runtest_call
elif when == "teardown":
ihook = item.ihook.pytest_runtest_teardown
else:
assert False, f"Unhandled runtest hook case: {when}"
reraise = (runner.Exit,)
if not item.config.getoption("usepdb", False):
reraise += (KeyboardInterrupt,)
return runner.CallInfo.from_call(
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
)

call = _call_runtest_hook(item, when, **kwds)
self._call_infos[item][when] = call
hook = item.ihook
report = hook.pytest_runtest_makereport(item=item, call=call)
Expand Down

0 comments on commit 493996e

Please sign in to comment.