gpt4 book ai didi

python-3.x - 如何将 Pytest 的日志附加到 Allure Report 中

转载 作者:行者123 更新时间:2023-12-03 23:14:31 69 4
gpt4 key购买 nike

我怎样才能将 pytest 的所有日志显示到 Allure 中。 stdout 和 stderr 用于什么?

请检查我所指的突出显示的代码
/image/1AePZ.png

最佳答案

标准输出 标准错误 用于显示对这些 Steam 的测试产生的输出。
为了让它们(和 日志 )填充在 Allure 报告中,您的测试或由测试执行的应用程序必须向相应的流产生输出。

import logging
import sys

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

def test_001():
logger.info('Logged INFO message')
logger.warning('Logged WARNING message')
logger.error('Logged ERROR message')
print('Message outputted to stdout')
print('Message outputted to stderr', file=sys.stderr)
assert 1 == 1

上面测试的输出:

enter image description here

关于python-3.x - 如何将 Pytest 的日志附加到 Allure Report 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53591282/

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