原因是 如果不进行格式化,会找不到报告输出的路径
具体代码如下:
import osimport pytestpath = 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')