我试图使用pytest-html插件从py生成html报告。测试运行,
@pytest.fixture()
def get_requests_info():
....
return [(0,'request1'),(1,'request2')]
@pytest.mark.parametrize("request", get_requests_info())
def test_a_vs_b(request):
.....
我应该如何设置环境夹具来创建html报告?
如果我简单地加上
@pytest.fixture(autouse=True)
def _environment(request):
request.config._environment.append(('foo'))
我得到的错误是,
@pytest.fixture(scope='session', autouse=True)
def environment(request):
"""Provide environment details for HTML report"""
> request.config._environment.extend([
('Python', platform.python_version()),
('Platform', platform.platform())])
E AttributeError: 'tuple' object has no attribute 'config'
有什么建议吗?
您有一个名为request
的fixture,它与pytest的内置request
fixture冲突。