Skip to content

Commit cc3f27a

Browse files
okkenflub
authored andcommitted
add suite timeout to header, linting fix.
1 parent 97a9ef5 commit cc3f27a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pytest_timeout.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import os
1111
import signal
1212
import sys
13-
import time
1413
import threading
14+
import time
1515
import traceback
1616
from collections import namedtuple
1717

@@ -47,8 +47,8 @@
4747
""".strip()
4848
SUITE_TIMEOUT_DESC = """
4949
Timeout in seconds for entire suite. Default is None which
50-
means no timeout. Timeout is checked between tests, and will not interrupt a test
51-
in progress.
50+
means no timeout. Timeout is checked between tests, and will not interrupt a test
51+
in progress.
5252
""".strip()
5353

5454
# bdb covers pdb, ipdb, and possibly others
@@ -205,15 +205,23 @@ def pytest_runtest_call(item):
205205
@pytest.hookimpl(tryfirst=True)
206206
def pytest_report_header(config):
207207
"""Add timeout config to pytest header."""
208+
timeout_header = []
209+
208210
if config._env_timeout:
209-
return [
211+
timeout_header.append(
210212
"timeout: %ss\ntimeout method: %s\ntimeout func_only: %s"
211213
% (
212214
config._env_timeout,
213215
config._env_timeout_method,
214216
config._env_timeout_func_only,
215217
)
216-
]
218+
)
219+
220+
suite_timeout = config.getoption("--suite-timeout")
221+
if suite_timeout:
222+
timeout_header.append("suite timeout: %ss" % suite_timeout)
223+
if timeout_header:
224+
return timeout_header
217225

218226

219227
@pytest.hookimpl(tryfirst=True)
@@ -534,7 +542,7 @@ def dump_stacks(terminal):
534542

535543
@pytest.hookimpl(tryfirst=True)
536544
def pytest_runtest_makereport(item, call):
537-
# only need to check timeout once, at the end, after teardown
545+
# only need to check timeout once, at the end, after teardown
538546
if call.when == "teardown":
539547
session = item.session
540548
config = session.config

0 commit comments

Comments
 (0)