【问题标题】:how to parametrize dependencies in Pytest如何在 Pytest 中参数化依赖项
【发布时间】:2019-01-17 20:08:20
【问题描述】:

假设有两个字符串要测试:“foo”和“bar”,每个字符串都有一个或多个对应的列表,例如对于 "foo" -> list1, list2, ... 和对于 "bar" -> list3, list4, ... 。参数化装饰器应该如何填充?

【问题讨论】:

  • 请多解释。给我们一个测试函数并解释你想要它做什么。告诉我们你是否也尝试过……

标签: python pytest


【解决方案1】:

您将按如下方式传递参数:

@pytest.mark.parametrize("foo, bar", [
    (list1, list2),
    (list3, list4)])
def test_xxx():
    ...

您可以使用this 代码作为示例。

【讨论】:

    猜你喜欢
    • 2016-12-25
    • 2019-05-31
    • 2023-02-21
    • 2023-01-03
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    相关资源
    最近更新 更多