# 日志捕获错误：不能同时使用 capsys 和 caplog

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

## 根因

在同一个测试函数中同时请求了 capsys 和 caplog fixture，pytest 不支持

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   def test_foo(caplog): ... 使用 caplog.text 检查日志
   ```
2. **** (85% 成功率)
   ```
   def test_foo(capsys): ... 使用 capsys.readouterr()
   ```

## 无效尝试

- **** — 可能失去需要的功能 (50% 失败率)
- **** — capsys 捕获 stdout，不捕获日志 (70% 失败率)
