Skip to content

Commit 79dea97

Browse files
Brian Okkenflub
Brian Okken
authored andcommitted
move suite timeout to pytest_runtest_protocol
1 parent cc3f27a commit 79dea97

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

pytest_timeout.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def pytest_runtest_protocol(item):
184184
if is_timeout and settings.func_only is False:
185185
hooks.pytest_timeout_cancel_timer(item=item)
186186

187+
# check suite timeout
188+
expire_time = item.session.config.stash[SUITE_TIMEOUT_KEY]
189+
if expire_time and (expire_time < time.time()):
190+
timeout = item.session.config.getoption("--suite-timeout")
191+
item.session.shouldfail = f"suite-timeout: {timeout} sec exceeded"
192+
187193

188194
@pytest.hookimpl(hookwrapper=True)
189195
def pytest_runtest_call(item):
@@ -538,15 +544,3 @@ def dump_stacks(terminal):
538544
thread_name = "<unknown>"
539545
terminal.sep("~", title="Stack of %s (%s)" % (thread_name, thread_ident))
540546
terminal.write("".join(traceback.format_stack(frame)))
541-
542-
543-
@pytest.hookimpl(tryfirst=True)
544-
def pytest_runtest_makereport(item, call):
545-
# only need to check timeout once, at the end, after teardown
546-
if call.when == "teardown":
547-
session = item.session
548-
config = session.config
549-
expire_time = config.stash[SUITE_TIMEOUT_KEY]
550-
if expire_time and (expire_time < time.time()):
551-
timeout = config.getoption("--suite-timeout")
552-
session.shouldfail = f"suite-timeout: {timeout} sec exceeded"

0 commit comments

Comments
 (0)