Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,16 @@ def _parse_marker(marker):
"""
if not marker.args and not marker.kwargs:
raise TypeError("Timeout marker must have at least one argument")
timeout = method = func_only = NOTSET = object() # noqa: N806
timeout = method = func_only = disable_debugger_detection = NOTSET = object() # noqa: N806
for kw, val in marker.kwargs.items():
if kw == "timeout":
timeout = val
elif kw == "method":
method = val
elif kw == "func_only":
func_only = val
elif kw == "disable_debugger_detection":
disable_debugger_detection = val
else:
msg = f"Invalid keyword argument for timeout marker: {kw}"
raise TypeError(msg)
Expand All @@ -434,7 +436,9 @@ def _parse_marker(marker):
method = None
if func_only is NOTSET:
func_only = None
return Settings(timeout, method, func_only, None)
if disable_debugger_detection is NOTSET:
disable_debugger_detection = None
return Settings(timeout, method, func_only, disable_debugger_detection)


def _validate_timeout(timeout, where):
Expand Down
21 changes: 21 additions & 0 deletions test_pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,27 @@ def test_marker_help(pytester):
result.stdout.fnmatch_lines(["@pytest.mark.timeout(*"])


def test_timeout_marker_disable_debugger_detection_keyword(pytester):
# the marker registration documents the disable_debugger_detection
# keyword, so using it must not fail with an invalid-kwarg TypeError
pytester.makepyfile(
"""
import pytest

@pytest.mark.timeout(60, disable_debugger_detection=True)
def test_marker_kwarg_ok():
assert True

@pytest.mark.timeout(60, method="thread", func_only=True,
disable_debugger_detection=True)
def test_marker_kwarg_with_others_ok():
assert True
"""
)
result = pytester.runpytest_subprocess()
result.assert_outcomes(passed=2)


@pytest.mark.parametrize(
("debugging_module", "debugging_set_trace"),
[
Expand Down
Loading