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_func_name_class_method(self):
self.assertEqual("TestServiceWithWrapper.test_wrapped", func_name(TestServiceWithWrapper.test_wrapped))
def test_func_name_undecorated_function(self):
self.assertEqual("my_acl", func_name(my_acl))
def test_decorate_view(self):
def myfunction():
pass
meth = 'POST'
decorated = decorate_view(myfunction, {}, meth)
self.assertEqual(decorated.__name__, "{0}__{1}".format(
func_name(myfunction), meth))
def test_func_name_string(self):
self.assertEqual("some_string", func_name("some_string"))
def test_func_name_decorated_function(self):
self.assertEqual("return_foo", func_name(return_foo))
def test_decorate_resource_view(self):
class MyResource(object):
def __init__(self, **kwargs):
pass
def myview(self):
pass
meth = 'POST'
decorated = decorate_view(_UnboundView(MyResource, 'myview'), {}, meth)
self.assertEqual(decorated.__name__, "{0}__{1}".format(
func_name(MyResource.myview), meth))
request.info['cors_checked'] = False
# We can't apply filters at this level, since "response" may not have
# been rendered into a proper Response object yet. Instead, give the
# request a reference to its api_kwargs so that a tween can apply them.
# We also pass the object we created (if any) so we can use it to find
# the filters that are in fact methods.
request.cornice_args = (args, ob)
return response
# return the wrapper, not the function, keep the same signature
if not is_string(view):
functools.update_wrapper(wrapper, view)
# Set the wrapper name to something useful
wrapper.__name__ = "{0}__{1}".format(func_name(view), method)
return wrapper
def __init__(self, klass, view):
self.unbound_view = getattr(klass, view.lower())
functools.update_wrapper(self, self.unbound_view)
self.__name__ = func_name(self.unbound_view)