今天在寫代碼的過程中遇到了這樣一個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
總結:遇到這種問題,以上兩種方法,二選一即可。