I'm using pytest0html to generate my html report. my test record tested values and I need to show a table of this values with prettytable in case of success. I think that i need to implement this hook:
@pytest.mark.optionalhook
def pytest_html_results_table_html(report, data):
if report.passed:
del data[:]
data.append(my_pretty_table_string)
# or data.append(report.extra.text)
But how to pass my_pretty_table_string to the hook function or how to edit report.extra.text from my test function ? Thank you for your help
Where is your
my_pretty_table_stringstored and generated?Please give more details to your question so we can help :)
pytest_html_results_table_htmlgetsreportobject frompytest_runtest_makereporthook. So you need to implementpytest_runtest_makereportto add your data to the result at 'call' step.then you can access
report.my_datainpytest_html_results_table_htmlhook.Alex