mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
fix: missing setup_hooks and teardown hooks
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
|
||||
# FROM: examples/httpbin/hooks.yml
|
||||
|
||||
from httprunner import HttpRunner, TConfig, TStep
|
||||
|
||||
|
||||
@@ -11,6 +12,7 @@ class TestCaseHooks(HttpRunner):
|
||||
"setup_hooks": ["${hook_print(setup)}"],
|
||||
"teardown_hooks": ["${hook_print(teardown)}"],
|
||||
"path": "examples/httpbin/hooks_test.py",
|
||||
"variables": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -104,7 +104,16 @@ def sort_request_by_custom_order(request: Dict) -> Dict:
|
||||
|
||||
|
||||
def sort_step_by_custom_order(step: Dict) -> Dict:
|
||||
custom_order = ["name", "variables", "request", "testcase", "extract", "validate"]
|
||||
custom_order = [
|
||||
"name",
|
||||
"variables",
|
||||
"request",
|
||||
"testcase",
|
||||
"setup_hooks",
|
||||
"teardown_hooks",
|
||||
"extract",
|
||||
"validate",
|
||||
]
|
||||
return sort_dict_by_custom_order(step, custom_order)
|
||||
|
||||
|
||||
@@ -116,6 +125,12 @@ def ensure_step_attachment(step: Dict) -> Dict:
|
||||
if "variables" in step:
|
||||
test_dict["variables"] = step["variables"]
|
||||
|
||||
if "setup_hooks" in step:
|
||||
test_dict["setup_hooks"] = step["setup_hooks"]
|
||||
|
||||
if "teardown_hooks" in step:
|
||||
test_dict["teardown_hooks"] = step["teardown_hooks"]
|
||||
|
||||
if "extract" in step:
|
||||
test_dict["extract"] = convert_extractors(step["extract"])
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class TConfig(BaseModel):
|
||||
name: Name
|
||||
verify: Verify = False
|
||||
base_url: BaseUrl = ""
|
||||
# Text: prepare variables in debugtalk.py, ${get_variable()}
|
||||
# Text: prepare variables in debugtalk.py, ${gen_variables()}
|
||||
variables: Union[VariablesMapping, Text] = {}
|
||||
setup_hooks: Hook = []
|
||||
teardown_hooks: Hook = []
|
||||
@@ -66,6 +66,8 @@ class TStep(BaseModel):
|
||||
request: Request = None
|
||||
testcase: Union[Text, Callable] = ""
|
||||
variables: VariablesMapping = {}
|
||||
setup_hooks: Hook = []
|
||||
teardown_hooks: Hook = []
|
||||
extract: Dict[Text, Text] = {}
|
||||
validators: Validators = Field([], alias="validate")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user