Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@wrapt.function_wrapper
def __call__(self, wrapped, instance, args, kwargs):
_self.assertEqual(type(self), wrapper)
called.append((args, kwargs))
_self.assertEqual(instance, None)
_self.assertEqual(args, _args)
_self.assertEqual(kwargs, _kwargs)
return wrapped(*args, **kwargs)
@wrapt.function_wrapper
def wrapper(wrapped, instance, args, kwargs):
called.append((args, kwargs))
self.assertEqual(instance, _instance)
self.assertEqual(args, _args)
self.assertEqual(kwargs, _kwargs)
return wrapped(*args, **kwargs)
@wrapt.function_wrapper
def import_wrapper(orig__import__, __, args, kwargs):
m = [None, None]
module_name, caller = module_name_from_import_args(args)
def cb():
if len(args) >= 3:
importer_locals = args[2]
if importer_locals is not None:
splits = module_name.split('.', 1)
if len(splits) == 2:
first, rest = splits
local = importer_locals.get(first, None)
if isinstance(local, ImportContextualizer):
new_args = list(args)
new_args[0] = rest