44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
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 插件
|
||
# ]) |