How to use exc method in fMBT

Best Python code snippet using fMBT_python

test_pep352.py

Source:test_pep352.py Github

copy

Full Screen

...81 self.assertTrue(issubclass(exc, superclasses[-1][1]),82 "%s is not a subclass of %s" % (exc.__name__,83 superclasses[-1][1].__name__))84 try: # Some exceptions require arguments; just skip them85 self.verify_instance_interface(exc())86 except TypeError:87 pass88 self.assertIn(exc_name, exc_set)89 exc_set.discard(exc_name)90 last_exc = exc91 last_depth = depth92 finally:93 inheritance_tree.close()94 self.assertEqual(len(exc_set), 0, "%s not accounted for" % exc_set)9596 interface_tests = ("length", "args", "message", "str", "unicode", "repr",97 "indexing")9899 def interface_test_driver(self, results): ...

Full Screen

Full Screen

exception.py

Source:exception.py Github

copy

Full Screen

...23 self.exc_val = None24 self.exc_tb = None25 self.error_type = const.EXC_TYPE.NOTSET26 self.max_exc_var_len = 16027 def set_exc(self, exc_type, exc_val, exc_tb):28 self.exc_type = exc_type29 self.exc_val = exc_val30 self.exc_tb = exc_tb31 def set_msg(self, msg):32 self.msg = msg33 def add_stack_info(self, filename, lineno, func_name, code, local_variables={}):34 self.stacks.append((filename, lineno, func_name, code, local_variables))35 @property36 def stacks_length(self):37 return len(self.stacks)38 def __repr__(self):39 if len(self.stacks) == 0:40 return self.msg41 def _repr(v):42 try:43 var_str = repr(v)44 if len(var_str) > self.max_exc_var_len:45 var_str = var_str[:self.max_exc_var_len] + " ..."46 return var_str47 except Exception:48 return 'UNREPRESENTABLE VALUE'49 content = ["Traceback (most recent call last):"]50 for filename, lineno, func_name, code, local_variables in self.stacks:51 content.append(' File %s, line %s in %s' % (filename, lineno, func_name))52 content.append(' %s' % (code, ))53 for k, v in six.iteritems(local_variables):54 content.append(' --> %s = %s' % (k, _repr(v)))55 content.append('')56 content.append("%s: %s" % (self.exc_type.__name__, self.msg))57 return "\n".join(content)58class CustomException(Exception):59 def __init__(self, error):60 self.error = error61EXC_EXT_NAME = "ricequant_exc"62def patch_user_exc(exc_val, force=False):63 exc_from_type = getattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.NOTSET)64 if exc_from_type == const.EXC_TYPE.NOTSET or force:65 setattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.USER_EXC)66 return exc_val67def patch_system_exc(exc_val, force=False):68 exc_from_type = getattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.NOTSET)69 if exc_from_type == const.EXC_TYPE.NOTSET or force:70 setattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.SYSTEM_EXC)71 return exc_val72def get_exc_from_type(exc_val):73 exc_from_type = getattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.NOTSET)74 return exc_from_type75def is_system_exc(exc_val):76 return get_exc_from_type(exc_val) == const.EXC_TYPE.SYSTEM_EXC77def is_user_exc(exc_val):78 return get_exc_from_type(exc_val) == const.EXC_TYPE.USER_EXC79class ModifyExceptionFromType(object):80 def __init__(self, exc_from_type, force=False):81 self.exc_from_type = exc_from_type82 self.force = force83 def __enter__(self):84 return self85 def __exit__(self, exc_type, exc_val, exc_tb):86 if exc_val is not None:87 exc_from_type = getattr(exc_val, EXC_EXT_NAME, const.EXC_TYPE.NOTSET)88 if self.force or exc_from_type == const.EXC_TYPE.NOTSET:89 setattr(exc_val, EXC_EXT_NAME, self.exc_from_type)90class RQUserError(Exception):91 ricequant_exc = const.EXC_TYPE.USER_EXC...

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