# PytestWarning: 检测到慢速测试：test_heavy_computation 耗时 5.23s

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

## 根因

pytest-slow-test 插件或自定义钩子标记了超过时间阈值的测试。这是警告而非错误，但如果警告被视为错误，则会导致失败。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use smaller datasets, mock heavy operations, or use caching.
   ```
2. **** (90% 成功率)
   ```
   @pytest.mark.slow
def test_heavy_computation():
    ...
Run with: pytest -m 'not slow'
   ```
3. **** (85% 成功率)
   ```
   @pytest.mark.slow_test_threshold(10)
def test_heavy_computation():
    ...
   ```

## 无效尝试

- **** — This reduces coverage and may remove important test cases. (90% 失败率)
- **** — This masks the performance issue and may allow very slow tests to persist. (80% 失败率)
- **** — If warnings are errors, the test suite still fails. (70% 失败率)
