【问题标题】:How to list installed packages and environment variables in pytest-html report?如何在 pytest-html 报告中列出已安装的包和环境变量?
【发布时间】:2019-12-10 16:16:44
【问题描述】:

我有一个带有 selenium + python 测试的框架,我需要使用pytest-html 在生成的报告中获取并显示有关已安装包和环境变量的信息。我唯一的想法是获取extra.html 并编写一个scipt,它将为包运行pip list,但这看起来像是一个开销。

非常感谢任何建议。

【问题讨论】:

    标签: selenium pytest pytest-html


    【解决方案1】:

    好吧,事实证明这很容易做到。我不得不使用常见的os 库:

    import os
        def _pytest_configure_(config):
            config.metadata['os'] = os.name
            config.metadata['PATH'] = os.environ['PATH']
            config.metadata['pwd'] = os.getcwd()
    

    并将其放入报告中,然后运行python3 -m pytest -v --html=report.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多