将元数据添加到 pytest_configure 文件给我内部错误 AttributeError: 'Config' object has no attribute 'metadata'

问题描述

我已经导入了 pytest 并安装了 pytest html,我正在尝试将元数据添加到 pytest_configure 文件中,但是当我在终端中运行测试时,我返回未找到内部服务器错误属性

这是 conftest 文件中的内容

#hook for adding environment info to html report
def pytest_configure(config):
    config.Metadata['Project Name'] = 'Hybrid Framework Practice' 
    config.Metadata['Module Name'] = 'Customers'
    config.Metadata['Tester'] = 'Amar'

#hook for delete/modify environment info to html report

@pytest.mark.optionalhook
def pytest_Metadata(Metadata):
    Metadata.pop("JAVA_HOME",None)
    Metadata.pop("Plugins",None)

这是我在终端中运行的:

pytest -v -s -n=2 --html=Reports\report.html testCases\test_login.py --browser chrome

我在 youtube 上关注一个人,它似乎使用完全相同的代码为他运行,但对我来说却失败了。 在没有 pytest_configure 代码的情况下运行上面的行工作正常并且测试通过 有谁知道缺少什么? 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)