pytest-htmlのようなプラグインを使用しているようです。 その場合、すべてのフックが提供されているかどうかのプラグインのドキュメントを確認してください。用
pytest-htmlのフックが提供される以下の あなたは、固定具からrequest.config._html.environment
を変更することで、レポートの環境セクションを変更、追加することができます
@pytest.fixture(autouse=True)
def _environment(request):
request.config._environment.append(('foo', 'bar'))
は、あなたが「余分を作成することにより、HTMLレポートに詳細を追加することができます'リストを作成します。次の例では、プラグインやconftest.py
ファイルに実装することができますpytest_runtest_makereport
フックを使用して余分の様々なタイプを追加します:
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', [])
if report.when == 'call':
# always add url to report
extra.append(pytest_html.extras.url('http://www.example.com/'))
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
# only add additional html on failure
extra.append(pytest_html.extras.html('<div>Additional HTML</div>'))
report.extra = extra
pytest-htmlプラグインを使用していますか? –