# TimeoutError: 测试在 30.0 秒后超时

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

## 根因

测试陷入无限循环、等待资源或执行非常慢的操作，超过了超时限制。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Add debug prints in the test to identify where it hangs, then fix the infinite loop or blocking call.
   ```
2. **** (85% 成功率)
   ```
   Use a shorter timeout and mock external dependencies to avoid real network calls: `@pytest.mark.timeout(5)`
   ```

## 无效尝试

- **** — This only masks the problem; the test may eventually fail or consume excessive resources. (85% 失败率)
- **** — Without a timeout, the test suite can hang indefinitely, blocking CI pipelines. (90% 失败率)
