首页 > 其他分享 >解决报错:AttributeError: ‘TestReport‘ object has no attribute ‘description‘

解决报错:AttributeError: ‘TestReport‘ object has no attribute ‘description‘

时间:2022-12-10 12:33:06浏览次数:39  
标签:description no attribute pytest 报错 report

此时我们只需要在conftest文件下加如下钩子函数就可以完美解决:

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    report.description = str(item.function.__doc__)
    report.nodeid = report.nodeid.encode("utf-8").decode("unicode_escape")  # 设置编码显示中文

标签:description,no,attribute,pytest,报错,report
From: https://www.cnblogs.com/longronglang/p/16971388.html

相关文章