# Failed: 超时（>30.0s）来自 pytest-timeout。

- **ID:** `python/pytest-timeout-test-timeout`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试超过默认的 30 秒超时，通常是由于阻塞的网络调用、死锁或无限循环。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   @pytest.mark.timeout(120)
def test_slow_operation():
    ...
   ```
2. **** (95% 成功率)
   ```
   @patch('requests.get')
def test_fetch(mock_get):
    mock_get.return_value.json.return_value = {'ok': True}
    ...
   ```

## 无效尝试

- **** — Hides the underlying hang and can cause CI to run indefinitely. (90% 失败率)
- **** — Makes the test slower and still fails; does not address the root cause. (80% 失败率)
