标签不生效的处理方法:PytestUnknownMarkWarning: Unknown pytest.mark.wallet - is this a typo?...


今天在写代码的过程中遇到了这样一个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

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM