如果我有一个简单的测试用例,我的自定义标记如下:
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
答案 0 :(得分:5)
您需要将标记名称添加到pytest.ini
以注册它们。见https://docs.pytest.org/en/latest/example/markers.html#registering-markers