標簽不生效的處理方法: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