标签不生效的处理方法:PytestUnknownMarkWarning: Unknown pytest.mark.wallet

今天在写代码的过程中遇到了这样一个warning:PytestUnknownMarkWarning: Unknown pytest.mark.test - is this a typo? 

处理办法:

参考文档:https://docs.pytest.org/en/latest/mark.html

单个标签的话:

在contest里面添加代码:

def pytest_configure(config):
config.addinivalue_line(
"markers", "test" # test 是标签名
)

多标签:

此方法只可以解决单个标签,如果有多个标签呢?

1)把上面的代码进行修改:

def pytest_configure(config):
marker_list = ["test1","test2","test3"] # 标签名集合
for markers in marker_list:
config.addinivalue_line(
"markers", markers
)

2)还有一种方法:添加pytest.int 配置文件

[pytest]
markers = test1
test2
test3

总结:遇到这种问题,以上两种方法,二选一即可。

原文地址:https://www.cnblogs.com/crystal1126/p/12217714.html