如何查看在 pytest 运行期间创建的正常打印输出? [英] How can I see normal print output created during pytest run?

查看:27
本文介绍了如何查看在 pytest 运行期间创建的正常打印输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我只想在我的代码中插入一些打印语句,然后看看当我执行它时会打印出什么.我通常使用现有的 pytest 测试来锻炼"它.但是当我运行这些时,我似乎看不到任何标准输出(至少在 PyCharm 中,我的 IDE).

Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to "exercise" it is with existing pytest tests. But when I run these, I don't seem able to see any standard output (at least from within PyCharm, my IDE).

是否有一种简单的方法可以在 pytest 运行期间查看标准输出?

Is there a simple way to see standard output during a pytest run?

推荐答案

-s 开关 禁用每次测试捕获(仅当测试失败时).

The -s switch disables per-test capturing (only if a test fails).

-s 等价于 --capture=no.

这篇关于如何查看在 pytest 运行期间创建的正常打印输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆