测试人社区

pytest-html生成的报告没有详细内容,求求老师帮忙回答

老师们好,最近使用pytest框架发现生成的报告没有详细内容,恳请赐教。
生成的报告如下图:


生成的报告里面没有详细信息,No log output captured.可是查遍了资料也没看到是在那儿配置的。
另外附上conftest.py文件,个人认为生成报告相关的配置都是在这里设置的

import pytest
from selenium import webdriver
from py._xmlgen import html

_driver = None

测试失败时添加截图和测试用例描述(用例的注释信息)

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item):
    """
    当测试失败的时候,自动截图,展示到html报告中
    :param item:
    """
    pytest_html = item.config.pluginmanager.getplugin('html')
    outcome = yield
    report = outcome.get_result()
    extra = getattr(report, 'extra', [])

    if report.when == 'call' or report.when == "setup":
        xfail = hasattr(report, 'wasxfail')
        if (report.skipped and xfail) or (report.failed and not xfail):
            file_name = report.nodeid.replace("::", "_") + ".png"
            screen_img = _capture_screenshot()
            if file_name:
                html = '<div><img src="data:image/png;base64,%s" alt="screenshot" style="width:600px;height:300px;" ' \
                       'onclick="window.open(this.src)" align="right"/></div>' % screen_img
                extra.append(pytest_html.extras.html(html))
        report.extra = extra
        report.description = str(item.function.__doc__)

        # 好像这句话会导致乱码,这里先注释掉
        # report.nodeid = report.nodeid.encode("utf-8").decode("unicode_escape")

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    report.description = str(item.function.__doc__)

@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
    cells.insert(1, html.th('Description'))
    cells.insert(2, html.th('Test_nodeid'))
    cells.pop(2)

@pytest.mark.optionalhook
def pytest_html_results_table_row(report, cells):
    cells.insert(1, html.td(report.description))
    cells.insert(2, html.td(report.nodeid))
    cells.pop(2)

def _capture_screenshot():
    """
    截图保存为base64
    :return:
    """
    return _driver.get_screenshot_as_base64()

@pytest.fixture(scope='module')
def driver():
    global _driver
    print('------------open browser------------')
    _driver = webdriver.Chrome()
    _driver.maximize_window()
    yield _driver
    print('------------close browser------------')
    _driver.quit()

执行文件的方式如下:
args = [’-m’, ‘homePageTest’, ‘–html=’ + ‘./report/’ + HTML_NAME]
pytest.main(args)

补充一下,期待的生成报告形式如下: