Skip to content

Commit 6f2a32f

Browse files
okkenflub
authored andcommitted
gate logic to once per test
1 parent 34bb2d8 commit 6f2a32f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pytest_timeout.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,11 @@ def dump_stacks(terminal):
533533

534534

535535
def pytest_runtest_makereport(item, call):
536-
session = item.session
537-
config = session.config
538-
expire_time = config.stash[SUITE_TIMEOUT_KEY]
539-
if expire_time and (expire_time < time.time()):
540-
timeout = config.getoption("--suite-timeout")
541-
session.shouldfail = f"suite-timeout: {timeout} sec exceeded"
536+
# only need to check timeout once, at the end, after teardown
537+
if call.when == "teardown":
538+
session = item.session
539+
config = session.config
540+
expire_time = config.stash[SUITE_TIMEOUT_KEY]
541+
if expire_time and (expire_time < time.time()):
542+
timeout = config.getoption("--suite-timeout")
543+
session.shouldfail = f"suite-timeout: {timeout} sec exceeded"

0 commit comments

Comments
 (0)