From 43a6e83ef0f61bb407a39ac2de5ce23fcd4f19df Mon Sep 17 00:00:00 2001 From: oyeong011 Date: Tue, 8 Sep 2026 11:49:25 +0900 Subject: [PATCH] Honor the advertised debugger detection marker override Confidence: high Scope-risk: narrow Tested: Regression fails before fix and passes after; full suite results recorded externally Not-tested: Other operating systems and Python versions --- pytest_timeout.py | 5 ++++- test_pytest_timeout.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pytest_timeout.py b/pytest_timeout.py index 192a16c..dfdb547 100644 --- a/pytest_timeout.py +++ b/pytest_timeout.py @@ -408,6 +408,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 + disable_debugger_detection = None for kw, val in marker.kwargs.items(): if kw == "timeout": timeout = val @@ -415,6 +416,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 +437,7 @@ def _parse_marker(marker): method = None if func_only is NOTSET: func_only = None - return Settings(timeout, method, func_only, 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 ff36c40..bb09970 100644 --- a/test_pytest_timeout.py +++ b/test_pytest_timeout.py @@ -729,3 +729,19 @@ def test_two(): result = pytester.runpytest_subprocess() result.stdout.fnmatch_lines(["*!! session-timeout: 1.0 sec exceeded !!!*"]) result.assert_outcomes(passed=1) + + +@pytest.mark.parametrize("disabled", [True, False]) +def test_debugger_detection_marker(pytester, disabled): + pytester.makepyfile(f""" + import pytest + import pytest_timeout + + @pytest.mark.timeout(0, disable_debugger_detection={disabled}) + def test_settings(request): + settings = pytest_timeout._get_item_settings(request.node) + assert settings.disable_debugger_detection is {disabled} + """) + result = pytester.runpytest_subprocess() + result.assert_outcomes(passed=1) + assert result.ret == 0