mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
change: format code
This commit is contained in:
+12
-7
@@ -379,6 +379,7 @@ def extend_validators(raw_validators, override_validators):
|
|||||||
def_validators_mapping.update(ref_validators_mapping)
|
def_validators_mapping.update(ref_validators_mapping)
|
||||||
return list(def_validators_mapping.values())
|
return list(def_validators_mapping.values())
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
## parse content with variables and functions mapping
|
## parse content with variables and functions mapping
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -408,8 +409,8 @@ def get_mapping_function(function_name, functions_mapping):
|
|||||||
if not found, then try to check if builtin function.
|
if not found, then try to check if builtin function.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
variable_name (str): variable name
|
function_name (str): function name
|
||||||
variables_mapping (dict): variables mapping
|
functions_mapping (dict): functions mapping
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
mapping function object.
|
mapping function object.
|
||||||
@@ -499,6 +500,7 @@ def parse_function_params(params):
|
|||||||
class LazyFunction(object):
|
class LazyFunction(object):
|
||||||
""" call function lazily.
|
""" call function lazily.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, function_meta, functions_mapping=None, check_variables_set=None):
|
def __init__(self, function_meta, functions_mapping=None, check_variables_set=None):
|
||||||
""" init LazyFunction object with function_meta
|
""" init LazyFunction object with function_meta
|
||||||
|
|
||||||
@@ -592,6 +594,7 @@ cached_functions_mapping = {}
|
|||||||
class LazyString(object):
|
class LazyString(object):
|
||||||
""" evaluate string lazily.
|
""" evaluate string lazily.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, raw_string, functions_mapping=None, check_variables_set=None, cached=False):
|
def __init__(self, raw_string, functions_mapping=None, check_variables_set=None, cached=False):
|
||||||
""" make raw_string as lazy object with functions_mapping
|
""" make raw_string as lazy object with functions_mapping
|
||||||
check if any variable undefined in check_variables_set
|
check if any variable undefined in check_variables_set
|
||||||
@@ -672,7 +675,7 @@ class LazyString(object):
|
|||||||
curr_position = match_start_position
|
curr_position = match_start_position
|
||||||
try:
|
try:
|
||||||
# find next $ location
|
# find next $ location
|
||||||
match_start_position = raw_string.index("$", curr_position+1)
|
match_start_position = raw_string.index("$", curr_position + 1)
|
||||||
remain_string = raw_string[curr_position:match_start_position]
|
remain_string = raw_string[curr_position:match_start_position]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
remain_string = raw_string[curr_position:]
|
remain_string = raw_string[curr_position:]
|
||||||
@@ -1004,7 +1007,8 @@ def _extend_with_testcase(test_dict, testcase_def_dict):
|
|||||||
"""
|
"""
|
||||||
# override testcase config variables
|
# override testcase config variables
|
||||||
testcase_def_dict["config"].setdefault("variables", {})
|
testcase_def_dict["config"].setdefault("variables", {})
|
||||||
testcase_def_variables = utils.ensure_mapping_format(testcase_def_dict["config"].get("variables", {}))
|
testcase_def_variables = utils.ensure_mapping_format(
|
||||||
|
testcase_def_dict["config"].get("variables", {}))
|
||||||
testcase_def_variables.update(test_dict.pop("variables", {}))
|
testcase_def_variables.update(test_dict.pop("variables", {}))
|
||||||
testcase_def_dict["config"]["variables"] = testcase_def_variables
|
testcase_def_dict["config"]["variables"] = testcase_def_variables
|
||||||
|
|
||||||
@@ -1016,8 +1020,8 @@ def _extend_with_testcase(test_dict, testcase_def_dict):
|
|||||||
|
|
||||||
# override name
|
# override name
|
||||||
test_name = test_dict.pop("name", None) \
|
test_name = test_dict.pop("name", None) \
|
||||||
or testcase_def_dict["config"].pop("name", None) \
|
or testcase_def_dict["config"].pop("name", None) \
|
||||||
or "testcase name undefined"
|
or "testcase name undefined"
|
||||||
|
|
||||||
# override testcase config name, output, etc.
|
# override testcase config name, output, etc.
|
||||||
testcase_def_dict["config"].update(test_dict)
|
testcase_def_dict["config"].update(test_dict)
|
||||||
@@ -1036,7 +1040,8 @@ def __prepare_config(config, project_mapping, session_variables_set=None):
|
|||||||
override_variables = utils.deepcopy_dict(project_mapping.get("variables", {}))
|
override_variables = utils.deepcopy_dict(project_mapping.get("variables", {}))
|
||||||
functions = project_mapping.get("functions", {})
|
functions = project_mapping.get("functions", {})
|
||||||
|
|
||||||
if isinstance(raw_config_variables, basestring) and function_regex_compile.match(raw_config_variables):
|
if isinstance(raw_config_variables, basestring) and function_regex_compile.match(
|
||||||
|
raw_config_variables):
|
||||||
# config variables are generated by calling function
|
# config variables are generated by calling function
|
||||||
# e.g.
|
# e.g.
|
||||||
# "config": {
|
# "config": {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class TestContext(ApiServerUnittest):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
loader.load_project_tests(os.path.join(os.getcwd(), "tests"))
|
loader.load_project_tests(os.path.join(os.getcwd(), "tests"))
|
||||||
project_mapping = loader.project_mapping
|
|
||||||
self.context = context.SessionContext(
|
self.context = context.SessionContext(
|
||||||
variables={"SECRET_KEY": "DebugTalk"}
|
variables={"SECRET_KEY": "DebugTalk"}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user