【发布时间】:2021-04-03 13:34:45
【问题描述】:
我正在尝试将屏幕截图附加到 Allure 报告。但是它一直失败并出现错误:
TyperError: Object of type AttachmentType is not JSON serializable
这是我的 conftest.py 中的代码:
import pytest
import allure
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
if report.whem == "call" and report.failed:
with allure.step("Failure screenshot"):
allure.attach.file(r'D:\image_01.png', allure.attachment_type.PNG)
环境: 视窗 10 蟒蛇3.8 pytest 6.2.2 诱惑-pytest 2.8.36 pywinauto 0.6.8
【问题讨论】: