diff --git a/examples/httpbin/validate_test.py b/examples/httpbin/validate_test.py index 22c5c7c8..fdf2c8a4 100644 --- a/examples/httpbin/validate_test.py +++ b/examples/httpbin/validate_test.py @@ -1,5 +1,6 @@ # NOTICE: Generated By HttpRunner. DO NOT EDIT! # FROM: examples/httpbin/validate.yml + from httprunner import HttpRunner, TConfig, TStep @@ -9,6 +10,7 @@ class TestCaseValidate(HttpRunner): "name": "basic test with httpbin", "base_url": "http://httpbin.org/", "path": "examples/httpbin/validate_test.py", + "variables": {}, } ) diff --git a/httprunner/compat.py b/httprunner/compat.py index 7f1fa2c3..d34c0001 100644 --- a/httprunner/compat.py +++ b/httprunner/compat.py @@ -113,6 +113,7 @@ def sort_step_by_custom_order(step: Dict) -> Dict: "teardown_hooks", "extract", "validate", + "validate_script", ] return sort_dict_by_custom_order(step, custom_order) @@ -137,6 +138,9 @@ def ensure_step_attachment(step: Dict) -> Dict: if "validate" in step: test_dict["validate"] = convert_validators(step["validate"]) + if "validate_script" in step: + test_dict["validate_script"] = step["validate_script"] + return test_dict diff --git a/httprunner/schema.py b/httprunner/schema.py index 227e4f20..986f6cb2 100644 --- a/httprunner/schema.py +++ b/httprunner/schema.py @@ -70,6 +70,7 @@ class TStep(BaseModel): teardown_hooks: Hook = [] extract: Dict[Text, Text] = {} validators: Validators = Field([], alias="validate") + validate_script: List[Text] = [] class TestCase(BaseModel):