fix(tests): use cross-platform pytest-timeout method#39881
Conversation
austinpickett
left a comment
There was a problem hiding this comment.
Reviewed by Hermes Agent — Approve ✅
Correct cross-platform fix. --timeout-method=signal uses SIGALRM, which doesn't exist on Windows (signal.SIGALRM → AttributeError), so Windows pytest runs crash with INTERNALERROR before any test runs. Switching to thread is pytest-timeout's documented cross-platform method. I verified --timeout-method=thread runs cleanly here (timeout method: thread, tests pass), and the change correctly keeps the 30s cap and updates the explanatory comment rather than dropping it.
Cross-ref: this is the proper, scoped home for this change. PR #41754 (security hardening) had snuck the same signal→thread switch in as an unrelated hunk — but bumped the timeout to 60s and deleted the comment. I've asked #41754 to drop that hunk in favor of this PR. LGTM here.
Summary
Windows pytest runs inherited
--timeout-method=signalfrompyproject.toml, and pytest-timeout implements that method withSIGALRM. Windows does not exposesignal.SIGALRM, so local suite runs crashed withINTERNALERROR: AttributeError: module 'signal' has no attribute 'SIGALRM'before reaching normal test failures.This switches the per-test timeout method to
thread, which is pytest-timeout's cross-platform mode. The repo still has the outer per-file subprocess timeout fromscripts/run_tests_parallel.py, so process-level hang protection remains in place while direct Windows pytest runs can execute.Fixes #39880
Changes
pyproject.toml: updates the pytest-timeout comment and changes--timeout-method=signalto--timeout-method=threadin[tool.pytest.ini_options]addopts.Validation
AttributeError: module 'signal' has no attribute 'SIGALRM'scripts/run_tests_parallel.pystill owns per-file process isolationTest plan
$env:BROWSER='echo'; C:\Apps\hermes\hermes-agent\venv\Scripts\python.exe -m pytest tests/ -q --tb=line 2>&1 | Select-String 'SIGALRM'before the change reproduced the crash withAttributeError: module 'signal' has no attribute 'SIGALRM'.$env:BROWSER='echo'; C:\Apps\hermes\hermes-agent\venv\Scripts\python.exe -m pytest tests/ -q --tb=lineafter the change reached ordinary test execution and stopped on a Python-level pytest-timeout intests/cli/test_surrogate_sanitization.py; noSIGALRMorINTERNALERRORappeared in the captured log.