This commit is contained in:
ruoyunbai 2025-09-29 12:33:49 +08:00
parent 93f2f16987
commit 73d580a62f

View File

@ -1104,8 +1104,40 @@ async def run_api_tests(config: TestConfig):
report_directory_path = (Path(REPORTS_DIR) / report_id).resolve()
# Prepare config
config_dict = config.dict()
mode = config_dict.pop('mode')
if hasattr(config, "model_dump"):
raw_config = config.model_dump(exclude_none=True)
else:
raw_config = config.dict(exclude_none=True)
mode = raw_config.pop('mode')
hidden_defaults = {
"categories": [],
"tags": [],
"ignore_ssl": True,
"output": "./test_reports",
"generate_pdf": True,
"custom_test_cases_dir": "./custom_testcases",
"stages_dir": "./custom_stages",
"llm_api_key": "sk-lbGrsUPL1iby86h554FaE536C343435dAa9bA65967A840B2",
"llm_base_url": "https://aiproxy.petrotech.cnpc/v1",
"llm_model_name": "deepseek-v3",
"use_llm_for_request_body": False,
"use_llm_for_path_params": False,
"use_llm_for_query_params": False,
"use_llm_for_headers": False,
"verbose": False
}
config_dict = {**hidden_defaults, **raw_config}
for default_path_key in ("custom_test_cases_dir", "stages_dir"):
default_path = config_dict.get(default_path_key)
if default_path:
try:
Path(default_path).mkdir(parents=True, exist_ok=True)
except Exception as path_error:
logger.warning(f"无法创建默认目录 {default_path}: {path_error}")
# Set file paths based on mode
if mode == 'yapi':