我一直在调试一个奇怪的pytest启动问题,并想检查是否有任何插件引起了问题。
是否可以启动pytest并要求它不加载任何插件?
根据我在文档中看到的,有一种方法只能关闭specific plugin by name。
答案 0 :(得分:1)
发布解决方案recommended in the comments:
python -c "import pkg_resources; print(' '.join('-p no:' + ' '.join(dist.get_entry_map(group='pytest11').keys()) for dist in pkg_resources.working_set if dist.get_entry_map(group='pytest11')))" | xargs pytest
这看起来有些不可思议,但是,如果对其进行分析和分解,它就会变得更加有意义:
pkg_resources
是setuptools
的一部分,它允许访问程序包资源文件,配置和设置配置.get_entry_map()
返回“入口点”对象的字典pytest11
入口点,因为这就是Pytest itself is using to discover plugins -p no:
command line argument中,这是Pytest禁用插件的方式受this answer的启发。