python
runtime_error
ai_generated
true
失败:来自 pytest-timeout 的超时(>60.0s)。
Failed: Timeout (>60.0s) from pytest-timeout.
ID: python/pytest-timeout-hung-test
80%修复率
86%置信度
0证据数
2024-07-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
测试阻塞在网络 I/O、未关闭的套接字、死锁或无限循环上;pytest-timeout 在配置的阈值后终止了它。
English
A test blocked on network I/O, an unclosed socket, a deadlock, or an infinite loop; pytest-timeout killed it after the configured threshold.
解决方案
-
90% 成功率
pytest --timeout=60 --timeout-method=thread -o faulthandler_timeout=55 tests/test_net.py
-
95% 成功率
from unittest import mock @mock.patch('app.client.requests.get') def test_fetch(mock_get): mock_get.return_value.json.return_value = {"ok": True} ... -
88% 成功率
@pytest.mark.timeout(5) def test_quick(): ...
无效尝试
常见但无效的做法:
-
85% 失败
Extends CI time without fixing the underlying hang.
-
95% 失败
CI hangs indefinitely; hides the bug.
-
90% 失败
A hang is not flakiness.