【问题标题】:How to apply multiple tags to a test case in pytest?如何将多个标签应用于pytest中的测试用例?
【发布时间】:2017-10-02 07:03:16
【问题描述】:

pytest 中,您可以使用标签标记测试用例。

@pytest.mark.windows
def test_will_fail():
    assert False

现在上面的测试用例被标记为'windows'。使用pytest -m windows 运行 pytest 将只执行标有“windows”标签的测试用例。

但是如果我想应用多个标签怎么办?例如我想用'windows'和'smoke'标记上面的测试用例。我该怎么做? (我还没有在 pytest 文档中看到一个例子。)

【问题讨论】:

    标签: tags pytest tagging markers


    【解决方案1】:

    这些只是您可以堆叠的Python decorators

    @pytest.mark.smoke
    @pytest.mark.windows
    def test_will_fail():
        assert False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-11
      • 2012-06-27
      相关资源
      最近更新 更多