pytest-html
pytest-html copied to clipboard
User Guide: Html tags description
in user guide many examples refer to html tags in strings as: https://pytest-html.readthedocs.io/en/latest/user_guide.html#additional-summary-information
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend(["<p>foo: bar</p>"])
by doing that, the <p> tag as well as other html tags (e.g. <div> or <h2>) are recognized as text.
The correct example would be to use py.xml package:
from py.xml import html
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend([html.p("foo: bar")])
Another useful example would be the one to add a log to the Results Summary:
from py.xml import html
def pytest_html_results_summary(prefix, summary, postfix):
postfix.extend([html.div("My additional log", class_='log')])
the User Guide shall be updated according to the correct html way to add information to the report sections.