import os import pytest if __name__ == '__main__': # 定义报告和临时文件目录 reports_dir = "reports" temp_dir = os.path.join(reports_dir, "temp") html_dir = os.path.join(reports_dir, "html") # 1. 执行 Pytest 测试 # -v: 输出详细信息 # --alluredir: 指定 Allure 临时数据目录 # -c: 指定 pytest.ini 配置文件路径 pytest.main([ "-v", "tests/", # 明确指定测试目录 f"--alluredir={temp_dir}", "-c=config/pytest.ini" ]) # 2. 生成 Allure HTML 报告 os.system(f'allure generate {temp_dir} -o {html_dir} --clean')