[英]Adding multiple XML attributes to a pytest xml in conftest.py
我有多個獨立運行的 pytest 腳本,我想構建一種機制,將 xml 屬性添加到腳本中的測試中,以便在收集時在 conftest.py 腳本中運行。 到目前為止,我在網上找到了一個電話:
request.config._xml.node_reporter(item.nodeid).add_attribute('spam', 'eggs')
可以在pytest_collection_modifyitems
鈎子中運行。 但是當我嘗試運行它時,我得到:
NameError: name 'request' is not defined
錯誤知道我錯過了什么嗎?
在文檔中挖掘了更多內容,發現如果將其添加到 conftest.py 中:
import pytest
@pytest.fixture(autouse=True)
def record_index(record_xml_attribute):
record_xml_attribute('index', '15')
它正是我需要的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.