Python 获取所有自定义标记的列表
如果我有一个带有自定义标记的简单测试用例,如:Python 获取所有自定义标记的列表,python,python-3.x,pytest,Python,Python 3.x,Pytest,如果我有一个带有自定义标记的简单测试用例,如: class TestClass: @pytest.mark.first def test_first(self): assert True @pytest.mark.second def test_second(self): assert True @pytest.mark.third def test_third(self): assert Tr
class TestClass:
@pytest.mark.first
def test_first(self):
assert True
@pytest.mark.second
def test_second(self):
assert True
@pytest.mark.third
def test_third(self):
assert True
如何获取整个自定义标记的列表,因为$py.test-v--markers
返回预定义标记的列表
@pytest.mark.skipif(condition)
@pytest.mark.xfail(condition, reason=None, run=True, raises=None)
@pytest.mark.parametrize(argnames, argvalues)
@pytest.mark.usefixtures(fixturename1, fixturename2, ...)
@pytest.mark.tryfirst
@pytest.mark.trylast
没有
@pytest.mark.first
@pytest.mark.second
@pytest.mark.third
您需要将标记名添加到
pytest.ini
以注册它们。请参见非常感谢,它很有效。但实际上,我认为有一种更简单的方法,比如@pytest.mark.first(annotate=“This is my marker”)
链接不起作用,它说:对不起,这个页面还不存在。