(
        self, hooks: Hooks, step_variables: VariablesMapping, hook_msg: Text,
    )
call hook actions.

        Args:
            hooks (list): each hook in hooks list maybe in two format.

                format1 (str): only call hook functions.
                    ${func()}
                format2 (dict): assignment, the value returned by hook function will be assigned to variable.
                    {"var": "${func()}"}

            step_variables: current step variables to call hook, include two special variables

                request: parsed request dict
                response: ResponseObject for current response

            hook_msg: setup/teardown request/testcase
call hook actions.
call hook actions .
def __call_hooks(
        self, hooks: Hooks, step_variables: VariablesMapping, hook_msg: Text,
    ) -> NoReturn:
        """ call hook actions.

        Args:
            hooks (list): each hook in hooks list maybe in two format.

                format1 (str): only call hook functions.
                    ${func()}
                format2 (dict): assignment, the value returned by hook function will be assigned to variable.
                    {"var": "${func()}"}

            step_variables: current step variables to call hook, include two special variables

                request: parsed request dict
                response: ResponseObject for current response

            hook_msg: setup/teardown request/testcase

        """
        logger.info(f"call hook actions: {hook_msg}")

        if not isinstance(hooks, List):
            logger.error(f"Invalid hooks format: {hooks}")
            return

        for hook in hooks:
            if isinstance(hook, Text):
                # format 1: ["${func()}"]
                logger.debug(f"call hook function: {hook}")
                parse_data(hook, step_variables, self.__project_meta.functions)
            elif isinstance(hook, Dict) and len(hook) == 1:
                # format 2: {"var": "${func()}"}
                var_name, hook_content = list(hook.items())[0]
                hook_content_eval = parse_data(
                    hook_content, step_variables, self.__project_meta.functions
                )
                logger.debug(
                    f"call hook function: {hook_content}, got value: {hook_content_eval}"
                )
                logger.debug(f"assign variable: {var_name} = {hook_content_eval}")
                step_variables[var_name] = hook_content_eval
            else:
                logger.error(f"Invalid hook format: {hook}")
def __call_hooks ( self , hooks : Hooks , step_variables : VariablesMapping , hook_msg : Text , ) -> NoReturn : logger . info ( f"call hook actions: {hook_msg}" ) if not isinstance ( hooks , List ) : logger . error ( f"Invalid hooks format: {hooks}" ) return for hook in hooks : if isinstance ( hook , Text ) : # format 1: ["${func()}"] logger . debug ( f"call hook function: {hook}" ) parse_data ( hook , step_variables , self . __project_meta . functions ) elif isinstance ( hook , Dict ) and len ( hook ) == 1 : # format 2: {"var": "${func()}"} var_name , hook_content = list ( hook . items ( ) ) [ 0 ] hook_content_eval = parse_data ( hook_content , step_variables , self . __project_meta . functions ) logger . debug ( f"call hook function: {hook_content}, got value: {hook_content_eval}" ) logger . debug ( f"assign variable: {var_name} = {hook_content_eval}" ) step_variables [ var_name ] = hook_content_eval else : logger . error ( f"Invalid hook format: {hook}" )