在conftest.py中向pytest XML添加多个XML属性



我有多个独立运行的pytest脚本,我想构建一种机制,将xml属性添加到脚本中的测试中,以便在集合上的conftest.py脚本中运行。到目前为止,我在网上找到了一个电话:

request.config._xml.node_reporter(item.nodeid).add_attribute('spam', 'eggs')

其可以在CCD_ 1钩子中运行。但当我试着运行这个时,我得到了:

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')

它正是我所需要的

最新更新