Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _attach_flexmock_methods(mock, flexmock_class, obj):
try:
for attr in UPDATED_ATTRS:
if hasattr(obj, attr):
if (_get_code(getattr(obj, attr)) is not
_get_code(getattr(flexmock_class, attr))):
return False
for attr in UPDATED_ATTRS:
_setattr(obj, attr, getattr(mock, attr))
except TypeError:
raise MockBuiltinError(
'Python does not allow you to mock builtin objects or modules. '
'Consider wrapping it in a class you can mock instead')
except AttributeError:
raise MockBuiltinError(
'Python does not allow you to mock instances of builtin objects. '
'Consider wrapping it in a class you can mock instead')
return True
def _attach_flexmock_methods(mock, flexmock_class, obj):
try:
for attr in UPDATED_ATTRS:
if hasattr(obj, attr):
if (_get_code(getattr(obj, attr)) is not
_get_code(getattr(flexmock_class, attr))):
return False
for attr in UPDATED_ATTRS:
_setattr(obj, attr, getattr(mock, attr))
except TypeError:
raise MockBuiltinError(
'Python does not allow you to mock builtin objects or modules. '
'Consider wrapping it in a class you can mock instead')
except AttributeError:
raise MockBuiltinError(
'Python does not allow you to mock instances of builtin objects. '
'Consider wrapping it in a class you can mock instead')
return True