有没有办法在每个测试的pytest-html报告中显示测试作者的名字?
发布于 2022-01-11 09:49:58
是。你可以做到的。在每个测试模块中添加__author__属性。
# test_add.py
__author__ = 'Vivek R'
def add(x, y):
return x + y
def test_add():
assert add(5, 4) == 9并在conftest.py文件中调用一些固定装置。
# conftest.py
from py.xml import html
import pytest
def pytest_html_results_table_header(cells):
cells.append(html.th("Author"))
def pytest_html_results_table_row(report, cells):
cells.append(html.td(report.author))
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.author = item.module.__author__

https://stackoverflow.com/questions/70651334
复制相似问题