如何解决如何将 pytest-html-reporter 生成的报告存储到自定义位置
我正在使用 pytest-html-reporter 0.2.4 插件来生成执行报告。 当我直接传递命令行参数“--html-report=./report/report.html”时,我能够在给定位置获取报告。
我想将报告存储在一个单独的位置,以执行日期(YYYYMMDD)作为文件夹名称,在 report_HHMM.html 中作为报告名称
这是我目前使用的逻辑
@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
time_var = datetime.datetime.Now()
# create report target dir
reports_dir = Path('reports',time_var.strftime('%Y%m%d'))
reports_dir.mkdir(parents=True,exist_ok=True)
# line to be add for addopts
args = f"--html-report=./{reports_dir}/report_{time_var.strftime('%H%M')}.html"
config.addinivalue_line("addopts",args)
print("inside config function",config.getini("addopts"))
这是我的 pytest.ini 文件
[pytest]
python_files = test_*
python_functions = test_*
python_classes = *Tests
addopts =
使用 config.getini("addopts") 我可以看到报告路径被添加到 addopts,但没有报告被添加到创建的目录
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。