如何从pytest html报告中的环境表中删除特定字段,如Packages、Platform、Plugins



我知道如何使用(config_metadata=None(删除pytest html报告中的整个"环境表",但有办法从该表中删除某些字段吗?我也可以使用(config_metadata['Python']='3+'(更新某些字段值,但找不到从html报表中删除该字段的方法。

如果您想删除开头的字段,请在conftest.py中使用此挂钩

def pytest_configure(config):
config._metadata.pop("Platform")
config._metadata.pop("Plugins")

否则,如果在测试会话结束时您想删除

@pytest.hookimpl(tryfirst=True)
def pytest_sessionfinish(session, exitstatus):
session.config._metadata.pop("JAVA_HOME")

最新更新