# 断言错误：断言 '' 在 'Some stderr output' 中

- **ID:** `python/pytest-capsys-stderr-not-captured`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

capsys fixture 默认捕获 stdout 但不捕获 stderr，或者测试错误地使用了 print 到 stderr。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   captured = capsys.readouterr()
assert 'expected' in captured.err
   ```
2. **** (90% 成功率)
   ```
   def test_foo(capfd):
    print('stderr', file=sys.stderr)
    captured = capfd.readouterr()
    assert 'stderr' in captured.err
   ```

## 无效尝试

- **** — capfd captures file descriptors, which may not be what you want. (60% 失败率)
- **** — This doesn't affect capture. (80% 失败率)
