如何为测试设置pytest标记列表?

时间:2019-04-08 16:49:55

标签: pytest markers

我正在使用2个标记“ @ pytest.mark.regression”和“ @ pytest.mark.smoke”。我需要所有测试都具有这2个标记,因此我想创建一个列表,例如 allmarkersList = [pytest.mark.regression,pytest.mark.smoke],我想将此标记@allmarkersList用于我的所有测试,这可能吗?

import pytest


allmarkers = [pytest.mark.regression, pytest.mark.smoke]


@pytest.mark.regression
def test_reg1():
    assert True


@pytest.mark.regression
def test_reg2():
    assert True


@pytest.mark.smoke
def test_smoke1():
    assert True


@pytest.mark.smoke
def test_smoke2():
    assert True


@allmarkers
def test_reg_and_smoke():
    print(all_marks)
    assert True

运行此命令时,出现以下错误-

 @allmarkers
E   TypeError: 'list' object is not callable

0 个答案:

没有答案