从pytest输出中删除失败

哈瓦德

Pytest对我来说是新的。我们尝试验证项目中是否有所有预期的文件。

我喜欢pytest输出的每个部分,但详细的FAILURES会使我们的非程序员感到困惑。

我们如何抑制FAILURES输出?

当前代码:

import os.path
import pytest

spec = {"expected_files": ["Dockerfile", "Duckerfile", "Daskerfile"]}

@pytest.mark.parametrize("expected_file", spec['expected_files'])
def test_expected_file_is_in_project(expected_file):
    assert os.path.isfile(expected_file), "File \""+expected_file+"\" not found in project"

运行“ pytest -v”命令后的输出

运行“ pytest -v”命令后的输出

喷枪

您可以在pytest将traceback(tb)选项设置为的情况下运行no以禁止显示traceback报告,即:

pytest --tb=no

请查看文档的“修改Python回溯打印”部分pytest

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章