如何导致Pytest打印一线追溯和捕获的输出?
当测试失败时,我需要 pytest 打印单行回溯以及失败测试的 stdout 和 stderr 输出。阅读 pytest 命令行参考后,似乎 --tb=line 和 --show-capture=all 选项应该这样做。在 test.py 文件的底部,我将此调用添加到 pytest.main:
pytest.main(["-v", "--tb=line", "--show-capture=all", __file__])
不幸的是,--tb=line 选项覆盖了 --show-capture 选项,并且 pytest 不显示捕获的 stdout 和 stderr。这对我来说似乎很奇怪,因为捕获的输出不是回溯的一部分,所以我不明白为什么 --tb 选项对 --show-capture 选项有任何影响。
是否有任何一组选项可以导致 pytest 打印单行回溯和捕获的输出?
When a test fails, I need pytest to print both a single line traceback and the output to stdout and stderr from the failed test. After reading the pytest command line reference, it seems that the --tb=line and --show-capture=all options should do that. At the bottom of my test.py file, I added this call to pytest.main:
pytest.main(["-v", "--tb=line", "--show-capture=all", __file__])
Unfortunately, the --tb=line option overrides the --show-capture option, and pytest doesn't show the captured stdout and stderr. This seems strange to me because the captured output is not part of the traceback, so I don't understand why the --tb option has any effect on the --show-capture option.
Is there any set of options that causes pytest to print both a single line traceback and the captured output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论