首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >pytest html报告生成

pytest html报告生成
EN

Stack Overflow用户
提问于 2016-09-14 04:04:36
回答 1查看 1.6K关注 0票数 0

我正在尝试使用pytest-html插件从py.test运行中生成html报告,

代码语言:javascript
运行
复制
@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报告的环境fixture?

如果我简单地加上,

代码语言:javascript
运行
复制
@pytest.fixture(autouse=True)
def _environment(request):
    request.config._environment.append(('foo'))

我得到的错误就像,

代码语言:javascript
运行
复制
    @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'

有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-14 22:56:10

您有一个名为request的fixture,它与pytest的内置request fixture冲突。我建议给你的fixture起个别的名字。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39478166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档