I'm using pytest-html 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? Continue reading...