mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-24 09:50:00 +08:00
refactor: make testcase
This commit is contained in:
@@ -74,22 +74,25 @@ def load_test_file(test_file: Text) -> Dict:
|
||||
return test_file_content
|
||||
|
||||
|
||||
def load_testcase_file(testcase_file: Text) -> Tuple[Dict, TestCase]:
|
||||
"""load testcase file and validate with pydantic model"""
|
||||
testcase_content = load_test_file(testcase_file)
|
||||
|
||||
def load_testcase(testcase: Dict) -> TestCase:
|
||||
path = testcase["config"]["path"]
|
||||
try:
|
||||
# validate with pydantic TestCase model
|
||||
testcase_obj = TestCase.parse_obj(testcase_content)
|
||||
testcase_obj = TestCase.parse_obj(testcase)
|
||||
except ValidationError as ex:
|
||||
err_msg = f"TestCase ValidationError:\nfile: {testcase_file}\nerror: {ex}"
|
||||
err_msg = f"TestCase ValidationError:\nfile: {path}\nerror: {ex}"
|
||||
logger.error(err_msg)
|
||||
raise exceptions.TestCaseFormatError(err_msg)
|
||||
|
||||
testcase_content["config"]["path"] = testcase_file
|
||||
testcase_obj.config.path = testcase_file
|
||||
return testcase_obj
|
||||
|
||||
return testcase_content, testcase_obj
|
||||
|
||||
def load_testcase_file(testcase_file: Text) -> TestCase:
|
||||
"""load testcase file and validate with pydantic model"""
|
||||
testcase_content = load_test_file(testcase_file)
|
||||
testcase_content.setdefault("config", {})["path"] = testcase_file
|
||||
testcase_obj = load_testcase(testcase_content)
|
||||
return testcase_obj
|
||||
|
||||
|
||||
def load_dot_env_file(dot_env_path: Text) -> Dict:
|
||||
|
||||
Reference in New Issue
Block a user