mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-21 20:42:25 +08:00
update parse_parameters
This commit is contained in:
@@ -20,18 +20,6 @@ class HttpRunner(object):
|
||||
failfast (bool): False/True, stop the test run on the first error or failure.
|
||||
http_client_session (instance): requests.Session(), or locust.client.Session() instance.
|
||||
|
||||
Attributes:
|
||||
project_mapping (dict): save project loaded api/testcases, environments and debugtalk.py module.
|
||||
{
|
||||
"debugtalk": {
|
||||
"variables": {},
|
||||
"functions": {}
|
||||
},
|
||||
"env": {},
|
||||
"def-api": {},
|
||||
"def-testcase": {}
|
||||
}
|
||||
|
||||
"""
|
||||
self.exception_stage = "initialize HttpRunner()"
|
||||
self.http_client_session = kwargs.pop("http_client_session", None)
|
||||
@@ -47,7 +35,7 @@ class HttpRunner(object):
|
||||
testcases (list): parsed testcases list
|
||||
|
||||
Returns:
|
||||
tuple: unittest.TestSuite()
|
||||
unittest.TestSuite()
|
||||
|
||||
"""
|
||||
def _add_teststep(test_runner, config, teststep_dict):
|
||||
@@ -165,10 +153,7 @@ class HttpRunner(object):
|
||||
"variables": [], # optional
|
||||
"request": {} # optional
|
||||
"refs": {
|
||||
"debugtalk": {
|
||||
"variables": {},
|
||||
"functions": {}
|
||||
},
|
||||
"functions": {},
|
||||
"env": {},
|
||||
"def-api": {},
|
||||
"def-testcase": {}
|
||||
|
||||
@@ -255,7 +255,7 @@ def substitute_variables(content, variables_mapping):
|
||||
|
||||
return content
|
||||
|
||||
def parse_parameters(parameters, variables_mapping, functions_mapping):
|
||||
def parse_parameters(parameters, variables_mapping=None, functions_mapping=None):
|
||||
""" parse parameters and generate cartesian product.
|
||||
|
||||
Args:
|
||||
@@ -265,7 +265,7 @@ def parse_parameters(parameters, variables_mapping, functions_mapping):
|
||||
(2) call built-in parameterize function, "${parameterize(account.csv)}"
|
||||
(3) call custom function in debugtalk.py, "${gen_app_version()}"
|
||||
|
||||
variables_mapping (dict): variables mapping loaded from debugtalk.py
|
||||
variables_mapping (dict): variables mapping loaded from testcase config
|
||||
functions_mapping (dict): functions mapping loaded from debugtalk.py
|
||||
|
||||
Returns:
|
||||
@@ -280,7 +280,10 @@ def parse_parameters(parameters, variables_mapping, functions_mapping):
|
||||
>>> parse_parameters(parameters)
|
||||
|
||||
"""
|
||||
variables_mapping = variables_mapping or {}
|
||||
functions_mapping = functions_mapping or {}
|
||||
parsed_parameters_list = []
|
||||
|
||||
for parameter in parameters:
|
||||
parameter_name, parameter_content = list(parameter.items())[0]
|
||||
parameter_name_list = parameter_name.split("-")
|
||||
@@ -542,7 +545,7 @@ def parse_tests(testcases, variables_mapping=None):
|
||||
"config": {
|
||||
"name": "desc1",
|
||||
"path": "testcase1_path",
|
||||
"variables": [], # optional
|
||||
"variables": {}, # optional
|
||||
"request": {} # optional
|
||||
"refs": {
|
||||
"debugtalk": {
|
||||
@@ -598,7 +601,7 @@ def parse_tests(testcases, variables_mapping=None):
|
||||
config_parameters = testcase_config.pop("parameters", [])
|
||||
cartesian_product_parameters_list = parse_parameters(
|
||||
config_parameters,
|
||||
{},
|
||||
testcase_config.get("variables", {}),
|
||||
project_mapping["functions"]
|
||||
) or [{}]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user