gpt4 book ai didi

python - py.test 记录通过的测试

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:47 26 4
gpt4 key购买 nike

我一遍又一遍地阅读文档,但我无法弄清楚如何让 py.test 写入日志以获取通过的测试。例如,如果我运行 "py.test --resultlog=mylog.txt myPytest.py" mylog.txt 对于通过的每个测试只有一行。我想在我的日志文件中记录的每个测试中添加其他内容,无论您是通过还是失败。例如,我需要知道它们运行的​​时间、一些输出数据等。如何让 py.test 在 py.test 日志文件中包含有关测试(通过和失败)的数据?

最佳答案

pytest 现在支持 -s 参数以防止捕获通过测试的日志记录调用。

pytest -s

来自documentation :

-s, –capture=no Normally stdout and stderr are captured and only shown for failing tests. The -s option can be used to disable capturing, showing stdcalls for print statements, logging calls, etc.

关于python - py.test 记录通过的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27853265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com