首页 > 解决方案 > pytest - 使用来自另一个插件的插件

问题描述

我使用这个带有cookiecutter的repo制作了一个新插件,我想使用它的另一个插件。

例如:当我跑步时pytest --useplugin

这应该运行:pytest --anotherplugin=12345 --useplugin

(更多命令行参数在后台运行。)

我在 pytest 文档中没有找到任何内容。

谢谢!

标签: pythonpluginspytestallure

解决方案


你最好的选择是看是否anotherplugin提供了一个 pytest 钩子供你使用。如果是这样,您可以在代码中使用以下内容:

@pytest.mark.optionalhook 
def optional_hook_name

如果它不提供钩子,您可能必须使用合适的 pytest 钩子 来传递相关参数。小心,使用不合适的 pytest 钩子将参数传递给另一个插件有时可能会导致竞争条件。


推荐阅读