(self, actions, hook_type)
call hook actions.

        Args:
            actions (list): each action in actions list maybe in two format.

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

            hook_type (enum): setup/teardown
call hook actions.
call hook actions .
def do_hook_actions(self, actions, hook_type):
        """ call hook actions.

        Args:
            actions (list): each action in actions list maybe in two format.

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

            hook_type (enum): setup/teardown

        """
        logger.log_debug("call {} hook actions.".format(hook_type))
        for action in actions:

            if isinstance(action, dict) and len(action) == 1:
                # format 1
                # {"var": "${func()}"}
                var_name, hook_content = list(action.items())[0]
                hook_content_eval = self.session_context.eval_content(hook_content)
                logger.log_debug(
                    "assignment with hook: {} = {} => {}".format(
                        var_name, hook_content, hook_content_eval
                    )
                )
                self.session_context.update_test_variables(
                    var_name, hook_content_eval
                )
            else:
                # format 2
                logger.log_debug("call hook function: {}".format(action))
                # TODO: check hook function if valid
                self.session_context.eval_content(action)
def do_hook_actions ( self , actions , hook_type ) : logger . log_debug ( "call {} hook actions." . format ( hook_type ) ) for action in actions : if isinstance ( action , dict ) and len ( action ) == 1 : # format 1 # {"var": "${func()}"} var_name , hook_content = list ( action . items ( ) ) [ 0 ] hook_content_eval = self . session_context . eval_content ( hook_content ) logger . log_debug ( "assignment with hook: {} = {} => {}" . format ( var_name , hook_content , hook_content_eval ) ) self . session_context . update_test_variables ( var_name , hook_content_eval ) else : # format 2 logger . log_debug ( "call hook function: {}" . format ( action ) ) # TODO: check hook function if valid self . session_context . eval_content ( action )