MCPcopy Index your code
hub / github.com/httprunner/httprunner / parse_variables_mapping

Function parse_variables_mapping

httprunner/parser.py:436–476  ·  view source on GitHub ↗
(
    variables_mapping: VariablesMapping, functions_mapping: FunctionsMapping = None
)

Source from the content-addressed store, hash-verified

434
435
436def parse_variables_mapping(
437 variables_mapping: VariablesMapping, functions_mapping: FunctionsMapping = None
438) -> VariablesMapping:
439
440 parsed_variables: VariablesMapping = {}
441
442 while len(parsed_variables) != len(variables_mapping):
443 for var_name in variables_mapping:
444
445 if var_name in parsed_variables:
446 continue
447
448 var_value = variables_mapping[var_name]
449 variables = extract_variables(var_value)
450
451 # check if reference variable itself
452 if var_name in variables:
453 # e.g.
454 # variables_mapping = {"token": "abc$token"}
455 # variables_mapping = {"key": ["$key", 2]}
456 raise exceptions.VariableNotFound(var_name)
457
458 # check if reference variable not in variables_mapping
459 not_defined_variables = [
460 v_name for v_name in variables if v_name not in variables_mapping
461 ]
462 if not_defined_variables:
463 # e.g. {"varA": "123$varB", "varB": "456$varC"}
464 # e.g. {"varC": "${sum_two($a, $b)}"}
465 raise exceptions.VariableNotFound(not_defined_variables)
466
467 try:
468 parsed_value = parse_data(
469 var_value, parsed_variables, functions_mapping
470 )
471 except exceptions.VariableNotFound:
472 continue
473
474 parsed_variables[var_name] = parsed_value
475
476 return parsed_variables
477
478
479def parse_parameters(

Callers 2

run_step_requestFunction · 0.90
parse_variablesMethod · 0.85

Calls 2

extract_variablesFunction · 0.85
parse_dataFunction · 0.85

Tested by

no test coverage detected