# pytest-timeout：超时错误：测试在 5.0 秒后超时

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

## 根因

测试花费的时间超过了 pytest-timeout 插件设置的超时时间，通常是由于无限循环、慢速 I/O 或网络延迟。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.11 | active | — | — |

## 解决方案

1. **** (80% 成功率)
   ```
   Optimize the test code to reduce execution time, e.g., by mocking slow external calls or reducing data size.
   ```
2. **** (85% 成功率)
   ```
   Use a higher timeout for specific tests with @pytest.mark.timeout(10) if the test legitimately requires more time.
   ```

## 无效尝试

- **** — Increasing the timeout value may allow the test to pass but does not address the underlying performance issue. (50% 失败率)
- **** — Removing the timeout entirely may cause CI pipelines to hang indefinitely. (70% 失败率)
