Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_update_annotations_modified_on_original(self):
def function():
pass
def wrapper(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
instance = wrapt.FunctionWrapper(function, wrapper)
if six.PY3:
self.assertEqual(instance.__annotations__, {})
else:
def run(*args):
instance.__annotations__
self.assertRaises(AttributeError, run, ())
override_annotations = { 'override_annotations': '' }
instance.__annotations__ = override_annotations
self.assertEqual(function.__annotations__, override_annotations)
self.assertEqual(instance.__annotations__, override_annotations)
def test_signature(self):
# Test preservation of function argument specification. It
# actually needs to match that of the adapter function the
# prototype of which was supplied via the dummy function.
if six.PY2:
return
def _adapter(arg1, arg2, *, arg3=None, **kwargs): pass
function1a_signature = str(inspect.signature(_adapter))
function1d_signature = str(inspect.signature(function1d))
self.assertEqual(function1a_signature, function1d_signature)
def test_update_qualname(self):
@passthru_decorator
def function():
pass
if six.PY3:
method = self.test_update_qualname
self.assertEqual(function.__qualname__,
(method.__qualname__ + '..function'))
function.__qualname__ = 'override_qualname'
self.assertEqual(function.__qualname__, 'override_qualname')
def test_signature(self):
# Test preservation of function argument specification. It
# actually needs to match that of the adapter function the
# prototype of which was supplied via the dummy function.
if six.PY2:
return
def _adapter(arg1, arg2, arg3=None, *args, **kwargs): pass
function1a_signature = str(inspect.signature(_adapter))
function1d_signature = str(inspect.signature(function1d))
self.assertEqual(function1a_signature, function1d_signature)