最小测试输出?

2024-04-29 14:57:24 发布

您现在位置:Python中文网/ 问答频道 /正文

当我运行pytest时,我得到一个非常详细的输出,带有难看的分隔符===============================================================================================================================

例如:

======================================================================================================= test session starts =======================================================================================================
platform linux -- Python 3.6.8, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/ycr/info1-labo-04
collected 1 item                                                                                                                                                                                                                  

test_armstrong.py .                                                                                                                                                                                                         [100%]

==================================================================================================== 1 passed in 0.03 seconds =====================================================================================================

是否有可能获得更紧凑的输出,例如:

...
----------------------------------------------------------------------
Ran 3 tests in 5.63s

OK

Tags: inpytesthomepytestsessionlinuxplatform
1条回答
网友
1楼 · 发布于 2024-04-29 14:57:24

你可以试试这个pytest命令

pytest -q  no-print-logs  disable-warnings  tb=no tests.py

它应该向你展示最起码的信息

-q->;安静输出

no-print-logs->;如果你有ony日志,不要打印它们

disable-warnings->;如果有任何警告,不要显示它们

tb=no->;如果有任何回溯,不要显示

相关问题 更多 >