Skip to content

Commit

Permalink
add suite timeout to header, linting fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
okken authored and flub committed Mar 7, 2024
1 parent 97a9ef5 commit cc3f27a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pytest_timeout.py
Expand Up @@ -10,8 +10,8 @@
import os
import signal
import sys
import time
import threading
import time
import traceback
from collections import namedtuple

Expand Down Expand Up @@ -47,8 +47,8 @@
""".strip()
SUITE_TIMEOUT_DESC = """
Timeout in seconds for entire suite. Default is None which
means no timeout. Timeout is checked between tests, and will not interrupt a test
in progress.
means no timeout. Timeout is checked between tests, and will not interrupt a test
in progress.
""".strip()

# bdb covers pdb, ipdb, and possibly others
Expand Down Expand Up @@ -205,15 +205,23 @@ def pytest_runtest_call(item):
@pytest.hookimpl(tryfirst=True)
def pytest_report_header(config):
"""Add timeout config to pytest header."""
timeout_header = []

if config._env_timeout:
return [
timeout_header.append(
"timeout: %ss\ntimeout method: %s\ntimeout func_only: %s"
% (
config._env_timeout,
config._env_timeout_method,
config._env_timeout_func_only,
)
]
)

suite_timeout = config.getoption("--suite-timeout")
if suite_timeout:
timeout_header.append("suite timeout: %ss" % suite_timeout)
if timeout_header:
return timeout_header


@pytest.hookimpl(tryfirst=True)
Expand Down Expand Up @@ -534,7 +542,7 @@ def dump_stacks(terminal):

@pytest.hookimpl(tryfirst=True)
def pytest_runtest_makereport(item, call):
# only need to check timeout once, at the end, after teardown
# only need to check timeout once, at the end, after teardown
if call.when == "teardown":
session = item.session
config = session.config
Expand Down

0 comments on commit cc3f27a

Please sign in to comment.