【问题标题】:pytest html report generationpytest html 报告生成
【发布时间】:2016-09-13 20:04:36
【问题描述】:

我正在尝试使用 pytest-html 插件从 py.test 运行生成 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'

有什么建议吗?

【问题讨论】:

    标签: html report pytest pytest-html


    【解决方案1】:

    您有一个名为 request 的夹具,它与 pytest 的内置 request 夹具冲突。我建议您将您的灯具称为其他名称。

    【讨论】:

      猜你喜欢
      • 2014-12-13
      • 1970-01-01
      • 2015-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多