【问题标题】:Is there a way to serve allure reports from python script?有没有办法从 python 脚本提供魅力报告?
【发布时间】:2020-06-24 09:35:30
【问题描述】:
我有一个端点,当它被命中时,会在我的 repo 中运行 pytest.main() 命令并运行所有 pytest 案例。
现在我想生成魅力报告并在特定主机上提供它们。我希望这通过 python 脚本发生有没有办法做到这一点?
我可以通过 python 脚本执行 CLI 参数来实现这一点,但该解决方案似乎是一个 hack。有没有更好的方法来做到这一点?
【问题讨论】:
标签:
python-3.x
pytest
allure
【解决方案1】:
import os
import subprocess
def generate():
"""
Run command to set allure path and generate allure report after the test run is over
"""
#stores report in raw format ( .txt and .json) in this location
reports = os.getcwd()+'/reports'
#stores processed reports int html format in this location
reportserver = os.getcwd()+'/reportserver'
command_generate_allure_report = ['allure generate '+reports+' -o '+reportserver+' --clean']
subprocess.call(command_generate_allure_report, shell=True)
执行此操作后,格式化报告将存储在该位置