# test_output (tests.test_cli.TestCli) ... ok

（尽管测试中有 print()，但没有显示捕获的 stdout）

- **ID:** `python/unittest-buffer-stdout-lost`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

unittest 的缓冲模式（`python -m unittest -b`）捕获 stdout/stderr 且仅在失败时打印；通过的测试不显示任何内容，调试打印不可见。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   Disable buffering for the run:
python -m unittest -v tests.test_cli.TestCli
# or remove -b from the command / CI config
   ```
2. **** (88% 成功率)
   ```
   Or capture stdout explicitly with contextlib.redirect_stdout:
import io, contextlib
buf = io.StringIO()
with contextlib.redirect_stdout(buf):
    run_cli(['--help'])
self.assertIn('usage', buf.getvalue())
   ```

## 无效尝试

- **** — stderr is also captured by buffer mode; still hidden on pass. (85% 失败率)
- **** — Turns the test red; not usable for debugging passing tests. (90% 失败率)
