原因是 如果不进行格式化,会找不到报告输出的路径
具体代码如下:
import os import pytest path = os.path.dirname(os.path.dirname(__file__)) # 项目APi路径 tempath = os.path.join(path, "report/temp") # 报告临时存放文件 reportpath = os.path.join(path, "report/report") # 报告打开路径 Casepath= os.path.join(path,"Testcase") # 测试集合路径 # print(path2) pytest.main([Casepath,"-s","--alluredir", tempath])#运行 test_case下所有测试用例 os.system(f'allure generate {tempath} -o {reportpath} -c') # os.system('allure generate tempath -o reportpath -c')