diff --git a/pytest_timeout.py b/pytest_timeout.py index 192a16c..f127a46 100644 --- a/pytest_timeout.py +++ b/pytest_timeout.py @@ -407,7 +407,7 @@ 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 @@ -415,6 +415,8 @@ def _parse_marker(marker): 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) @@ -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): diff --git a/test_pytest_timeout.py b/test_pytest_timeout.py index 178cb3e..7ff4cf6 100644 --- a/test_pytest_timeout.py +++ b/test_pytest_timeout.py @@ -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"), [