mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-05 15:59:33 +08:00
rename keyword: extract_binds => extractors
This commit is contained in:
@@ -56,9 +56,9 @@ class ResponseObject(object):
|
||||
except AttributeError:
|
||||
raise exception.ParseResponseError("failed to extract bind variable in response!")
|
||||
|
||||
def extract_response(self, extract_binds):
|
||||
def extract_response(self, extractors):
|
||||
""" extract content from requests.Response
|
||||
@param (list) extract_binds
|
||||
@param (list) extractors
|
||||
[
|
||||
{"resp_status_code": "status_code"},
|
||||
{"resp_headers_content_type": "headers.content-type"},
|
||||
@@ -68,11 +68,11 @@ class ResponseObject(object):
|
||||
@return (OrderDict) variable binds ordered dict
|
||||
"""
|
||||
extracted_variables_mapping = OrderedDict()
|
||||
extract_binds_order_dict = utils.convert_to_order_dict(extract_binds)
|
||||
extract_binds_order_dict = utils.convert_to_order_dict(extractors)
|
||||
|
||||
for key, field in extract_binds_order_dict.items():
|
||||
if not isinstance(field, utils.string_type):
|
||||
raise exception.ParamsError("invalid extract_binds in testcase extract_binds!")
|
||||
raise exception.ParamsError("invalid extractors in testcase!")
|
||||
|
||||
extracted_variables_mapping[key] = self.extract_field(field)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class Runner(object):
|
||||
},
|
||||
"body": '{"name": "user", "password": "123456"}'
|
||||
},
|
||||
"extract_binds": [], # optional
|
||||
"extractors": [], # optional
|
||||
"validators": [], # optional
|
||||
"setup": [], # optional
|
||||
"teardown": [] # optional
|
||||
@@ -100,7 +100,9 @@ class Runner(object):
|
||||
raise exception.ParamsError("URL or METHOD missed!")
|
||||
|
||||
run_times = int(testcase.get("times", 1))
|
||||
extract_binds = testcase.get("extract_binds", [])
|
||||
extractors = testcase.get("extractors") \
|
||||
or testcase.get("extractor") \
|
||||
or testcase.get("extract_binds", [])
|
||||
validators = testcase.get("validators", [])
|
||||
setup_actions = testcase.get("setup", [])
|
||||
teardown_actions = testcase.get("teardown", [])
|
||||
@@ -115,7 +117,7 @@ class Runner(object):
|
||||
resp = self.http_client_session.request(url=url, method=method, **parsed_request)
|
||||
resp_obj = response.ResponseObject(resp)
|
||||
|
||||
extracted_variables_mapping = resp_obj.extract_response(extract_binds)
|
||||
extracted_variables_mapping = resp_obj.extract_response(extractors)
|
||||
self.context.bind_variables(extracted_variables_mapping, level="testset")
|
||||
|
||||
resp_obj.validate(validators, self.context.get_testcase_variables_mapping())
|
||||
@@ -142,7 +144,7 @@ class Runner(object):
|
||||
"name": "testcase description",
|
||||
"variable_binds": [], # optional, override
|
||||
"request": {},
|
||||
"extract_binds": {}, # optional
|
||||
"extractors": {}, # optional
|
||||
"validators": {} # optional
|
||||
},
|
||||
testcase12
|
||||
|
||||
Reference in New Issue
Block a user