python
runtime_error
ai_generated
true
Failed: Timeout (>60.0s) from pytest-timeout.
ID: python/pytest-timeout-hanging-test
80%Fix Rate
88%Confidence
0Evidence
2024-12-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
A test blocks longer than the configured timeout, often due to a network call, deadlock, or an unclosed resource waiting on input.
generic中文
测试阻塞超过配置的超时时间,通常由网络调用、死锁或未关闭的资源等待输入引起。
Workarounds
-
90% success
from unittest import mock def test_fetch(monkeypatch): monkeypatch.setattr('myapp.client.requests.get', lambda *a, **k: FakeResp()) assert myapp.client.fetch() -
85% success
# pytest.ini [pytest] timeout = 60 timeout_method = signal # on failure, pytest prints the stack where the test hung
Dead Ends
Common approaches that don't work:
-
85% fail
Hides the underlying hang; CI duration balloons and the real bug (deadlock, missing mock) persists.
-
95% fail
Test suite hangs indefinitely in CI, blocking the whole pipeline until the job-level timeout.
-
90% fail
Loses coverage and leaves the bug in production code undetected.