python
runtime_error
ai_generated
true
Failed: Timeout (>30.0s) from pytest-timeout.
ID: python/pytest-timeout-test-hangs
80%Fix Rate
85%Confidence
0Evidence
2026-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.x | active | — | — | — |
Root Cause
A test blocks on I/O (network, subprocess, lock) longer than the configured timeout. pytest-timeout kills the test but the underlying hang often indicates a missing mock or a deadlock.
generic中文
测试在 I/O(网络、子进程、锁)上阻塞时间超过配置的超时。pytest-timeout 会终止测试,但底层挂起通常表明缺少 mock 或存在死锁。
Workarounds
-
90% success
Use the thread method to get a Python traceback at timeout: pytest --timeout=30 --timeout-method=thread -s
-
95% success
Mock the blocking dependency (e.g. requests.get) or use a fake server; this usually reveals the missing mock.
Dead Ends
Common approaches that don't work:
-
70% fail
Slows the suite and hides the real hang; CI eventually times out at the job level.
-
90% fail
Hung tests block CI indefinitely, requiring manual cancellation.