Python, объект py.test 'HTMLReport' не имеет атрибута 'execute'
Я пытаюсь добавить скриншоты в мой отчет 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'
Откуда это взялось?
1 ответ
Решение
Проблема была вызвана тем, что я добавил в класс pytest_runtest_makereport. Это должно быть снаружи. Закрыто