# AttributeError: 'CaptureFixture' 对象没有属性 'readouterr'

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

## 根因

在新版 pytest 中，`capsys` 返回 `CaptureFixture` 对象，读取输出的方法为 `readouterr()`。拼写错误（如 `read_outerr`）或误用 `capfd` 会导致此错误。

## 版本兼容性

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

## 解决方案

1. **** (97% 成功率)
   ```
   Use the correct method:
def test_out(capsys):
    print('hi')
    captured = capsys.readouterr()
    assert captured.out == 'hi\n'
   ```

## 无效尝试

- **** — These methods don't exist on CaptureFixture. (80% 失败率)
- **** — Same API surface; typo persists. (70% 失败率)
