如何使 Pytest 中的输出不那么冗长?

And*_*i B 5 python verbosity verbose pytest tavern

我正在使用 tavern 运行 pytest 来进行一个小型测试 API 项目。测试失败,会给我带来一堆详细的错误以及我期望得到的响应(为什么失败)。我怎样才能让 pytest 不那么冗长?

我尝试了 pytest --tb=short、pytest -vv、pytest --tavern-beta-new-traceback ,但没有一个按预期工作,只是告诉我失败的原因。就像是:

E   tavern.util.exceptions.TestFailError: Test 'Do something' failed:
    - Status code was 200, expected 300
-------------------------------------------------------- Captured log call --------------------------------------------------------
base.py                     41 ERROR    Status code was 200, expected 300
==================================================== 1 failed in 0.38 seconds =====================================================
Run Code Online (Sandbox Code Playgroud)

也许 tavern 处理错误或 pytest 的方式有问题?

小智 5

运行pytest -vv应该会让你的输出更加详细。如果您希望输出不那么冗长,请尝试pytest -qpytest --quiet