pytest-html
pytest-html copied to clipboard
Extra in report is duplicated
import pytest
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
extra.append(pytest_html.extras.html('<p>Print something</p>'))
report.extra = extra
In the report, the text is displayed twice:
Print something
Print something
Can you try this with the latest release? 4.0.0rc0
i found that if you add if report.when == "call": before extra.append, then no dup. though i'm not sure what when == call means. docs
i found that if you add
if report.when == "call":beforeextra.append, then no dup. though i'm not sure whatwhen == callmeans. docs
That is correct, to avoid having the append happen multiple you have to add the when == "call" gate (as shown in the docs).
Each test has 3 stages ("when"s), setup, call, and teardown. This is core pytest.