change: format code

This commit is contained in:
debugtalk
2019-12-05 20:07:51 +08:00
parent cab54c9c9a
commit 9225848ffb
2 changed files with 12 additions and 8 deletions

View File

@@ -379,6 +379,7 @@ def extend_validators(raw_validators, override_validators):
def_validators_mapping.update(ref_validators_mapping)
return list(def_validators_mapping.values())
###############################################################################
## 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.
Args:
variable_name (str): variable name
variables_mapping (dict): variables mapping
function_name (str): function name
functions_mapping (dict): functions mapping
Returns:
mapping function object.
@@ -499,6 +500,7 @@ def parse_function_params(params):
class LazyFunction(object):
""" call function lazily.
"""
def __init__(self, function_meta, functions_mapping=None, check_variables_set=None):
""" init LazyFunction object with function_meta
@@ -592,6 +594,7 @@ cached_functions_mapping = {}
class LazyString(object):
""" evaluate string lazily.
"""
def __init__(self, raw_string, functions_mapping=None, check_variables_set=None, cached=False):
""" make raw_string as lazy object with functions_mapping
check if any variable undefined in check_variables_set
@@ -672,7 +675,7 @@ class LazyString(object):
curr_position = match_start_position
try:
# 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]
except ValueError:
remain_string = raw_string[curr_position:]
@@ -1004,7 +1007,8 @@ def _extend_with_testcase(test_dict, testcase_def_dict):
"""
# override testcase config 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_dict["config"]["variables"] = testcase_def_variables
@@ -1016,8 +1020,8 @@ def _extend_with_testcase(test_dict, testcase_def_dict):
# override name
test_name = test_dict.pop("name", None) \
or testcase_def_dict["config"].pop("name", None) \
or "testcase name undefined"
or testcase_def_dict["config"].pop("name", None) \
or "testcase name undefined"
# override testcase config name, output, etc.
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", {}))
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
# e.g.
# "config": {

View File

@@ -9,7 +9,6 @@ class TestContext(ApiServerUnittest):
def setUp(self):
loader.load_project_tests(os.path.join(os.getcwd(), "tests"))
project_mapping = loader.project_mapping
self.context = context.SessionContext(
variables={"SECRET_KEY": "DebugTalk"}
)