Есть вот такой код с парой комментов, может чем-то поможет
# hook для перехвата и модификации данных результатов тестов
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
# Добавление значений в таблицу - значения берем из атрибута
doc функции и глобальных переменных
report.description = str( item.function.
doc )
report.a = str( item.module.log['a'] )
report.b = str( item.module.log['b'] )
report.sum = str( item.module.log['sum'] )
# Добавление html и image блоков в результат - значения берем из глобальных переменных
extra = getattr(report, 'extra', [])
if report.when == 'call':
# вставляем html-блок
if item.module.log_html != 'none':
extra.append(pytest_html.extras.html( item.module.log_html ))
# вставляем img-блок (картинка будет встроена в отчет)
if item.module.log_img != 'none':
extra.append(pytest_html.extras.image( item.module.log_img, mime_type='image/jpg', extension='jpg' ))
# вставляем img-блок с url-ссылкой
if item.module.log_img_url != 'none':
extra.append(pytest_html.extras.image( item.module.log_img_url ))
report.extra = extra