Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support timeout trigger skip instead of fail #153

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ def pytest_configure(config):
"evaluating any fixtures used in the test. The "
"*disable_debugger_detection* keyword, when set to True, disables "
"debugger detection, allowing breakpoint(), pdb.set_trace(), etc. "
"to be interrupted",
"to be interrupted. The *skip* keyword, when set to True, the timeout "
"trigger pytest.skip() instead of pytest.fail().",
)

settings = get_env_settings(config)
config._env_timeout = settings.timeout
config._env_timeout_method = settings.method
config._env_timeout_func_only = settings.func_only
config._env_timeout_disable_debugger_detection = settings.disable_debugger_detection
config._env_timeout_trigger_skip = settings.skip


@pytest.hookimpl(hookwrapper=True)
Expand Down Expand Up @@ -436,6 +438,7 @@ def timeout_sigalrm(item, settings):
current to stderr and then raise an AssertionError, thus
terminating the test.
"""
skip = settings.skip
if not settings.disable_debugger_detection and is_debugging():
return
__tracebackhide__ = True
Expand All @@ -445,7 +448,10 @@ def timeout_sigalrm(item, settings):
dump_stacks()
if nthreads > 1:
write_title("Timeout", sep="+")
pytest.fail("Timeout >%ss" % settings.timeout)
if skip:
pytest.skip("Timeout >%ss" % settings.timeout)
else:
pytest.fail("Timeout >%ss" % settings.timeout)


def timeout_timer(item, settings):
Expand Down
Loading