gpt4 book ai didi

python - pytest 时禁用每个测试 "dots"

转载 作者:行者123 更新时间:2023-12-01 00:42:48 29 4
gpt4 key购买 nike

我有大约 10^5 次测试的参数化测试套件。我正在调试因此引发的错误,即使用 -x旗帜。就像这样:

pytest tests.py -x

这里的问题是这个命令用 . 扰乱了终端。对应每个测试。这是不希望的(因为我没有任何 xfaild 或其他东西 - 仅通过或未通过;并且由于测试数量):

............................................................................................................................................................................................................ [  5%]
............................................................................................................................................................................................................ [ 11%]
............................................................................................................................................................................................................ [ 17%]

如何禁用这个“点”并只留下进度条?也许一些插件?尝试过-q但点仍在打印。

最佳答案

您可以实现pytest_report_teststatus() Hook 到您的 conftest.py 中。它返回一个元组结果-类别、短字母和详细单词。

def pytest_report_teststatus(report, config):
if report.passed and report.when == "call":
return report.outcome, "", report.outcome.upper()

每个测试都会调用该钩子(Hook) 3 次,report.when 设置为 "setup""call"“拆解”。如果测试在“call”阶段通过,上面的回调会将短字母设置为空字符串。

关于python - pytest 时禁用每个测试 "dots",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57226800/

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