更新:下面显示的消息不受pytest各种"-q“静音选项的控制。他们来自TeamCity插件.
见下面的答案。
我已经阅读了用于沉默pytest的现有堆栈溢出答案,但是没有人告诉我如何沉默大量冗余的“测试传递”消息。我有太多的错误,我的错误会从页面上滚动出来。(因为这是py魅力,所以我可以添加args,但是我不控制命令行。)
帮助!
为了清晰起见,我想删除以下消息:(
test_lang.py::TestParsing::test_parsing PASSED [ 2%]
test_lang.py::TestParsing::test_xxx PASSED [ 3%]
test_mixin.py::TestHeadSettable::test_headsettable PASSED [ 4%]
test_mixin.py::TestPathy::test_tree_null_creation PASSED ..。
test_uf.py::TestListyStructure::test_extend[UnitList] PASSED [ 96%]
test_uf.py::TestListyStructure::test_extend[UnitListWrapper] PASSED [ 97%]
test_uf.py::TestListyStructure::test_slice[UnitList] PASSED [ 98%]
test_uf.py::TestListyStructure::test_slice[UnitListWrapper] PASSED [ 99%]
test_uf.py::TestUnitMisc::test_main PASSED [100%]
============================= 101 passed in 0.49s ==============================发布于 2019-09-12 15:52:39
(有关PyCharm最新版本的详细信息,请参阅底部)
PyCharm2018的解决方案PYCHARM正在悄悄地安装一个叫做TeamCity的pytest插件。它需要这个插件来跟踪哪些测试成功或失败。您可以通过编辑Pycharm运行程序脚本来禁用此插件的加载。(恶心!)
在Mac上,此文件位于: /Applications/PyCharm.app/Contents/helpers/pycharm/_jb_pytest_runner.py
添加如下所示的行,以禁用TeamCity的加载:
...
jb_doc_args("pytest", args)
# We need to preparse numprocesses because user may set it using ini file
plugins_to_load = [] # <--- ADD THIS LINE TO AVOID TEAMCITY PLUGIN
config_result = real_prepare_config(args, plugins_to_load)
...UPDATE FOR 2019.3 and later.
On a Mac this file is located at: /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py
...
jb_doc_args("pytest", args)
plugins_to_load = [] # ADDED THIS LINE TO AVOID EXTRA PYTEST PRINTING
...https://stackoverflow.com/questions/57901794
复制相似问题