Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 获取所有自定义标记的列表_Python_Python 3.x_Pytest - Fatal编程技术网

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”)
链接不起作用,它说:
对不起,这个页面还不存在。