python - pytest - 使用来自另一个插件的插件
问题描述
我使用这个带有cookiecutter的repo制作了一个新插件,我想使用它的另一个插件。
例如:当我跑步时pytest --useplugin
这应该运行:pytest --anotherplugin=12345 --useplugin
(更多命令行参数在后台运行。)
我在 pytest 文档中没有找到任何内容。
谢谢!
解决方案
你最好的选择是看是否anotherplugin
提供了一个 pytest 钩子供你使用。如果是这样,您可以在代码中使用以下内容:
@pytest.mark.optionalhook
def optional_hook_name
如果它不提供钩子,您可能必须使用合适的 pytest 钩子 来传递相关参数。小心,使用不合适的 pytest 钩子将参数传递给另一个插件有时可能会导致竞争条件。
推荐阅读
- python - 使用 python API 将可空整数插入 bigquery 时出错
- three.js - webgl(three.js)中的物质画家出口gltf完全是黑色的
- java - ZipOutputStream 的文件名编码错误
- r - ggplot2中的二维等高线颜色图
- angular - Angular [disabled]="MyBoolean" 不工作
- javascript - 根据变量的值更改 div 的颜色
- python - 单行python语句中`==`和`in`的奇怪行为
- android - 将 TextView 显示为 ImageView 以启用缩放
- winapi - 是否有用于启用 Windows 1803 的半透明标题栏的 Win32 API?
- prettyfaces - PrettyFaces 和 Rewrite 库 - 我们如何在 PrettyFaces 从 URL 查询参数设置属性之前调用 bean 方法?