commit c773a6b5041fd803faebf3787bb5ac1d4ed28e4f Author: luhaitao Date: Thu Oct 30 10:02:58 2025 +0000 上传文件至 / diff --git a/runner.py b/runner.py new file mode 100644 index 0000000..3d724ea --- /dev/null +++ b/runner.py @@ -0,0 +1,44 @@ +import pytest +import os +from pathlib import Path + +# 获取测试文件路径 +current_dir = Path(__file__).parent +test_file = current_dir / "Test_Case" / "test_apps.py" + +# 检查路径 +print(f"测试文件路径: {test_file}") +print(f"路径是否存在: {test_file.exists()}") + +# 临时禁用 allure 插件(如果冲突) +os.environ["PYTEST_DISABLE_PLUGIN_AUTOLOAD"] = "allure-pytest" + +# # 执行测试 +pytest.main([str(test_file), "-s"]) + + +# import pytest +# import os +# from pathlib import Path +# import sys +# current_dir = Path(__file__).parent +# test_file = current_dir / "Test_Case" / "test_apps.py" +# report_path = str(current_dir / "report.html") +# +# print(f"Python 解释器路径: {sys.executable}") +# print(f"pytest 版本: {pytest.__version__}") +# print(f"测试文件路径: {test_file}") +# print(f"路径是否存在: {test_file.exists()}") +# print(f"报告将生成至: {report_path}") +# +# # 禁用 Allure 插件 +# os.environ["PYTEST_DISABLE_PLUGIN_AUTOLOAD"] = "allure-pytest" +# +# # 执行测试并生成报告(显式启用 pytest-html) +# pytest.main([ +# str(test_file), +# "-s", +# f"--html={report_path}", +# "--self-contained-html", +# "-p", "pytest_html" # 手动加载 pytest-html 插件 +# ]) \ No newline at end of file