python
runtime_error
ai_generated
true
Failed: 超时(>30.0s)来自 pytest-timeout。
Failed: Timeout (>30.0s) from pytest-timeout.
ID: python/pytest-timeout-test-timeout
80%修复率
90%置信度
0证据数
2024-10-02首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
测试超过默认的 30 秒超时,通常是由于阻塞的网络调用、死锁或无限循环。
English
A test exceeds the default 30s timeout, often due to a blocking network call, deadlock, or an infinite loop.
解决方案
-
90% 成功率
@pytest.mark.timeout(120) def test_slow_operation(): ... -
95% 成功率
@patch('requests.get') def test_fetch(mock_get): mock_get.return_value.json.return_value = {'ok': True} ...
无效尝试
常见但无效的做法:
-
90% 失败
Hides the underlying hang and can cause CI to run indefinitely.
-
80% 失败
Makes the test slower and still fails; does not address the root cause.