#8973·pytest

终端报告无法打印

作者: gaborbernat创建于 2021年8月3日更新于 2026年9月24日
标签type: bugtopic: reportingtype: regression
python
# test_a.py
def test_foo(request):
    reporter = request.config.pluginmanager.getplugin("terminalreporter")
    reporter.ensure_newline()
    reporter.write("magic", flush=True)

如果通过 pytest 运行上述文件,则不会在输出中写入任何内容。

内容来源: pytest-dev/pytest