From d633777c5ee617c17751a4d10114b6c1beab23d6 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Tue, 10 Sep 2024 11:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=9D=E5=A7=8B=E5=8C=96=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpfpt/utils/request/case_data_parse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/httpfpt/utils/request/case_data_parse.py b/httpfpt/utils/request/case_data_parse.py index 0b38896..5e33ea4 100644 --- a/httpfpt/utils/request/case_data_parse.py +++ b/httpfpt/utils/request/case_data_parse.py @@ -12,9 +12,11 @@ from pydantic import ValidationError from httpfpt.common.errors import RequestDataParseError +from httpfpt.common.json_handler import read_json_file from httpfpt.common.log import log from httpfpt.common.yaml_handler import read_yaml from httpfpt.db.redis import redis_client +from httpfpt.enums.case_data_type import CaseDataType from httpfpt.schemas.case_data import CaseCacheData from httpfpt.utils.file_control import get_file_hash, get_file_property, search_all_case_data_files from httpfpt.utils.pydantic_parser import parse_error @@ -41,7 +43,11 @@ def case_data_init(pydantic_verify: bool) -> None: """ all_case_data_files = search_all_case_data_files() for case_data_file in all_case_data_files: - case_data = read_yaml(case_data_file) + file_type = get_file_property(case_data_file)[2] + if file_type == CaseDataType.JSON: + case_data = read_json_file(case_data_file) + else: + case_data = read_yaml(case_data_file) filename = get_file_property(case_data_file)[0] file_hash = get_file_hash(case_data_file) case_data.update({'filename': filename, 'file_hash': file_hash})