首页 > 解决方案 > 如何在 pytest-html 报告中删除环境表

问题描述

我正在尝试删除 pytest-html 报告中存在的环境表,但我不知道该怎么做?

我已附上 pytest-html 报告 在此处输入图像描述

标签: pythonpython-3.xpytestpytest-html

解决方案


文档中的相关位置指出:

Environment 部分由 pytest-metadata, 插件提供,可以通过pytest_configure钩子访问:

def pytest_configure(config):
    config._metadata['foo'] = 'bar'

修改config._metadata将影响呈现的“环境”部分。如果要完全删除它,请将元数据设置为None

# conftest.py

def pytest_configure(config):
    config._metadata = None

推荐阅读