How to use call_tagexception_handler method in fMBT

Best Python code snippet using fMBT_python

aalmodel.py

Source:aalmodel.py Github

copy

Full Screen

...91 return self._variables['action'](action_name)92 else:93 raise Exception('''Exception handler "%s('%s', %s)" returned unexpected value: %s''' %94 (handler_name, action_name, exc, rv))95 def call_tagexception_handler(self, handler_name, tag_name, exc):96 rv = self._variables[handler_name](tag_name, exc)97 if type(rv) in [bool, types.NoneType]:98 return rv99 else:100 raise Exception('''Exception handler "%s('%s', %s)" returned unexpected value: %s''' %101 (handler_name, tag_name, exc, rv))102 def reset(self):103 # initialize model104 fmbt._g_actionName = "AAL: initial_state"105 rv = self.call(self.initial_state)106 self._push_variables = [107 v for v in self.__class__.push_variables_set108 if (v in self._variables and109 type(eval(v, self._variables)) not in [types.ModuleType, types.ClassType])110 ]111 return rv112 def adapter_init():113 return True114 def init(self):115 # initialize adapter116 fmbt._g_actionName = "AAL: adapter_init"117 rv = self.call(self.adapter_init)118 return rv119 def adapter_exit(verdict, reason):120 return121 def aexit(self, verdict, reason):122 if not self._adapter_exit_executed:123 self._adapter_exit_executed = True124 fmbt._g_actionName = "AAL: adapter_exit"125 self.adapter_exit.im_func(verdict, reason)126 def adapter_execute(self, i, adapter_call_arguments = ()):127 if not 0 < i <= len(self._all_names):128 raise IndexError('Cannot execute action %s adapter code' % (i,))129 if self._all_types[i-1] == "input":130 try:131 fmbt._g_actionName = self._all_names[i-1]132 fmbt._g_testStep += 1133 rv = self.call(self._all_adapters[i-1], adapter_call_arguments)134 fmbt._g_testStep -= 1135 if rv == None: return i136 else: return rv137 except Exception, exc:138 if 'adapter_exception_handler' in self._variables:139 return self.call_exception_handler('adapter_exception_handler', self._all_names[i-1], exc)140 else:141 raise142 else:143 self._log("AAL model: adapter_execute for an output action in AAL." +144 "This should take place in observe().\n")145 return 0146 def tag_execute(self, i):147 if not 0 < i <= len(self._all_tagnames):148 raise IndexError('Cannot execute tag %s adapter code' % (i,))149 fmbt._g_actionName = "tag: " + self._all_tagnames[i-1]150 try:151 rv = self.call(self._all_tagadapters[i-1])152 except Exception, exc:153 if 'adapter_exception_handler' in self._variables:154 return self.call_tagexception_handler('adapter_exception_handler', self._all_tagnames[i-1], exc)155 else:156 raise157 return rv158 def model_execute(self, i):159 if not 0 < i <= len(self._all_names):160 # If adapter execute returns 0, that is reports unidentified action,161 # test engine checks if executing an unidentified action is ok by162 # calling model_execute(0). In AAL/Python it is never ok.163 return 0164 fmbt._g_actionName = self._all_names[i-1]165 if i in self._enabled_actions_stack[-1] or self.call(self._all_guards[i-1]):166 self.call(self._all_bodies[i-1])167 if self._has_serial:168 for postfunc in getattr(self, self._all_bodies[i-1].__name__ + "_postcall", []):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful