【问题标题】:Improving pytest end report to show individual passed tests?改进 pytest 结束报告以显示单个通过的测试?
【发布时间】:2016-11-16 17:17:21
【问题描述】:

在这个上搜索了一段时间,很惊讶没有找到很多东西。我目前正在使用 pytest 并希望改进已通过测试的细节。

这里的目的是以相同的详细程度报告与失败一起通过的各个测试。使用站点中的示例进行失败的测试:

$ pytest
======= test session starts ========
platform linux -- Python 3.5.2, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: $REGENDOC_TMPDIR, inifile:
collected 1 items

test_sample.py F

======= FAILURES ========
_______ test_answer ________

def test_answer():
    >       assert func(3) == 5
    E       assert 4 == 5
    E        +  where 4 = func(3)

test_sample.py:5: AssertionError
======= 1 failed in 0.12 seconds ========

我正在寻找一种方法以类似的方式报告通过的测试,可能带有自定义文本?

如果不是在最终报告中添加自定义文本的方法就足够了。

这是可能的还是我在这里尝试了一些不正确的东西?

干杯, R.

【问题讨论】:

    标签: python pytest


    【解决方案1】:

    py.test -s 显示成功测试的stdout

    这与上面示例中的失败结果不同,但在成功通过时,您不会触发任何断言。

    所以你会看到你的测试在成功通过后将输出到stdout

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 2022-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多