Skip to content

Commit 333f3be

Browse files
okkenflub
authored andcommitted
suite-timeout -> session-timeout
1 parent 79dea97 commit 333f3be

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ docs/_build/
5555

5656
# Virtual Envs
5757
.env*
58+
venv
5859

5960
# IDE
6061
.idea

pytest_timeout.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
__all__ = ("is_debugging", "Settings")
22-
SUITE_TIMEOUT_KEY = pytest.StashKey[float]()
22+
SESSION_TIMEOUT_KEY = pytest.StashKey[float]()
2323

2424

2525
HAVE_SIGALRM = hasattr(signal, "SIGALRM")
@@ -45,8 +45,8 @@
4545
When specified, disables debugger detection. breakpoint(), pdb.set_trace(), etc.
4646
will be interrupted by the timeout.
4747
""".strip()
48-
SUITE_TIMEOUT_DESC = """
49-
Timeout in seconds for entire suite. Default is None which
48+
SESSION_TIMEOUT_DESC = """
49+
Timeout in seconds for entire session. Default is None which
5050
means no timeout. Timeout is checked between tests, and will not interrupt a test
5151
in progress.
5252
""".strip()
@@ -87,13 +87,13 @@ def pytest_addoption(parser):
8787
help=DISABLE_DEBUGGER_DETECTION_DESC,
8888
)
8989
group.addoption(
90-
"--suite-timeout",
90+
"--session-timeout",
9191
action="store",
92-
dest="suite_timeout",
92+
dest="session_timeout",
9393
default=None,
9494
type=float,
9595
metavar="SECONDS",
96-
help=SUITE_TIMEOUT_DESC,
96+
help=SESSION_TIMEOUT_DESC,
9797
)
9898
parser.addini("timeout", TIMEOUT_DESC)
9999
parser.addini("timeout_method", METHOD_DESC)
@@ -159,12 +159,12 @@ def pytest_configure(config):
159159
config._env_timeout_func_only = settings.func_only
160160
config._env_timeout_disable_debugger_detection = settings.disable_debugger_detection
161161

162-
timeout = config.getoption("--suite-timeout")
162+
timeout = config.getoption("--session-timeout")
163163
if timeout is not None:
164164
expire_time = time.time() + timeout
165165
else:
166166
expire_time = 0
167-
config.stash[SUITE_TIMEOUT_KEY] = expire_time
167+
config.stash[SESSION_TIMEOUT_KEY] = expire_time
168168

169169

170170
@pytest.hookimpl(hookwrapper=True)
@@ -184,11 +184,11 @@ 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]
187+
# check session timeout
188+
expire_time = item.session.config.stash[SESSION_TIMEOUT_KEY]
189189
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"
190+
timeout = item.session.config.getoption("--session-timeout")
191+
item.session.shouldfail = f"session-timeout: {timeout} sec exceeded"
192192

193193

194194
@pytest.hookimpl(hookwrapper=True)
@@ -223,9 +223,9 @@ def pytest_report_header(config):
223223
)
224224
)
225225

226-
suite_timeout = config.getoption("--suite-timeout")
227-
if suite_timeout:
228-
timeout_header.append("suite timeout: %ss" % suite_timeout)
226+
session_timeout = config.getoption("--session-timeout")
227+
if session_timeout:
228+
timeout_header.append("session timeout: %ss" % session_timeout)
229229
if timeout_header:
230230
return timeout_header
231231

test_pytest_timeout.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ def test_foo():
604604
]
605605
)
606606

607-
def test_suite_timeout(pytester):
607+
608+
def test_session_timeout(pytester):
608609
pytester.makepyfile(
609610
"""
610611
import time, pytest
@@ -614,6 +615,6 @@ def test_foo(i):
614615
time.sleep(1)
615616
"""
616617
)
617-
result = pytester.runpytest_subprocess("--suite-timeout", "0.5")
618-
result.stdout.fnmatch_lines(["*!! suite-timeout: 0.5 sec exceeded !!!*"])
618+
result = pytester.runpytest_subprocess("--session-timeout", "0.5")
619+
result.stdout.fnmatch_lines(["*!! session-timeout: 0.5 sec exceeded !!!*"])
619620
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)