Skip to content

fix: accept documented disable_debugger_detection kwarg in timeout marker - #216

Merged
flub merged 1 commit into
pytest-dev:mainfrom
rahul05ranjan:fix-timeout-marker-disable-debugger-detection
Oct 31, 2026
Merged

flub merged 1 commit into
pytest-dev:mainfrom
rahul05ranjan:fix-timeout-marker-disable-debugger-detection

Conversation

@rahul05ranjan

Copy link
Copy Markdown
Contributor

Fixes #215.

Problem

The timeout marker registration documents a disable_debugger_detection keyword (it also appears in pytest --markers output), but _parse_marker() has no branch for it, so:

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

kills the whole session with INTERNALERROR> TypeError: Invalid keyword argument for timeout marker: disable_debugger_detection.

The CLI flag and ini setting of the same name work; only the documented marker keyword is broken.

Fix

Parse disable_debugger_detection in _parse_marker() as a keyword-only argument and include it in the returned Settings, so the existing _validate_disable_debugger_detection() validation in _get_item_settings() applies to it like the other keyword arguments. Unknown keywords are still rejected.

Verification

  • Before the fix, the reproduction above fails the session with the INTERNALERROR above; after the fix the test passes.
  • New regression test test_timeout_marker_disable_debugger_detection_keyword covers the keyword both alone and combined with method/func_only via pytester.runpytest_subprocess().
  • Direct unit check: _parse_marker(pytest.mark.timeout(60, disable_debugger_detection=True)) now returns Settings(timeout=60, method=None, func_only=None, disable_debugger_detection=True), while pytest.mark.timeout(10, bogus=True) is still rejected with TypeError.
  • Note: HEAD's parser.addini(..., type="float") requires pytest >= 8.4, and my system pytest is 8.3.5, so I could not run the full suite locally as-is; I verified the end-to-end behavior with a local one-line addini shim (coercing the new "float" ini type, unrelated to this change) on top of this patch. The new pytester test runs in the project's normal CI matrix.

…rker

The timeout marker registration (and the --markers help text) documents
a disable_debugger_detection keyword, but _parse_marker() rejected it with
'TypeError: Invalid keyword argument for timeout marker', turning any test
using @pytest.mark.timeout(..., disable_debugger_detection=True) into an
INTERNALERROR at collection/run time.

Parse the keyword (keyword-only, consistent with the documented marker
signature) and pass it through so the existing per-marker validation in
_get_item_settings() applies to it like the other keyword arguments.

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>

@flub flub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate if you do not let LLMs write the text of issues. It's really hard to read. Please put in the effort to communicate in your own words.

@flub
flub merged commit b621dc2 into pytest-dev:main Oct 31, 2026
12 checks passed
@flub

flub commented Oct 31, 2026

Copy link
Copy Markdown
Member

Please read the commit message, this needed only two lines of explanation to communicate clearly.

@pytest-dev pytest-dev deleted a comment from rahul05ranjan Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documented disable_debugger_detection marker keyword raises TypeError (INTERNALERROR)

2 participants