각 테스트의 '세부 정보 표시'섹션에 html 콘텐츠를 추가하거나 결과 표 사용자 정의 (예 : 티켓 열 추가)를 통해 각 테스트에 맞춤 html을 삽입 할 수 있습니다. 콘텐츠에 당신이 <p>some html</p>
을 대체 할 수있는 경우
첫 번째 가능성
는 간단합니다, 당신은 당신의 conftest.py
@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':
extra.append(pytest_html.extras.html('<p>some html</p>'))
report.extra = extra
에 다음을 추가 할 수 있습니다.
두 번째 솔루션은 다음과 같습니다
@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
cells.insert(1, html.th('Ticket'))
@pytest.mark.optionalhook
def pytest_html_results_table_row(report, cells):
cells.insert(1, html.td(report.ticket))
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.ticket = some_function_that_gets_your_ticket_number()
는 항상 항목 개체와 현재 테스트에 액세스 할 수 있는지 기억이 당신이 필요로하는 정보를 검색하는 도움이 될 수 있습니다.