gpt4 book ai didi

Python,py.test 'HTMLReport' 对象没有属性 'execute'

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:54 29 4
gpt4 key购买 nike

我正在尝试将自动测试的屏幕截图添加到我的 pytest-html 报告中

我已添加到plugin.py:

def pytest_runtest_makereport(__multicall__, item):
report = __multicall__.execute()
extra = getattr(report, 'extra', [])
if report.when == 'call':
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
url = TestSetup.selenium.current_url
report.extra.append(extras.url(url))
screenshot = TestSetup.selenium.get_screenshot_as_base64()
report.extra.append(extras.image(screenshot, 'Screenshot'))
html = TestSetup.selenium.page_source.encode('utf-8')
report.extra.append(extra.text(html, 'HTML'))
report.extra.append(extra.html(html.div('Additional HTML')))
report.extra = extra
return report

但是运行时

py.test --html=report.html filename.py 

我明白了

INTERNALERROR>   File "C:\Python27\lib\site-packages\pytest_html\plugin.py", line 288, in pytest_runtest_makereport
INTERNALERROR> report = __multicall__.execute()
INTERNALERROR> AttributeError: 'HTMLReport' object has no attribute 'execute'

它从哪里来?

最佳答案

问题是由于我在类中添加了 pytest_runtest_makereport 引起的。应该在外面。已关闭

关于Python,py.test 'HTMLReport' 对象没有属性 'execute',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35363771/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com