How to use the wrapt.six.exec_ function in wrapt

To help you get started, we’ve selected a few wrapt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionelmc / python-lazy-object-proxy / tests / test_adapter_py33.py View on Github external
import wrapt

from wrapt import six

DECORATORS_CODE = """
import wrapt

def prototype(arg1, arg2, *, arg3=None, **kwargs): pass
@wrapt.decorator(adapter=prototype)
def adapter1(wrapped, instance, args, kwargs):
    '''adapter documentation'''
    return wrapped(*args, **kwargs)
"""

decorators = imp.new_module('decorators')
six.exec_(DECORATORS_CODE, decorators.__dict__, decorators.__dict__)

def function1(arg1, arg2):
    '''documentation'''
    return arg1, arg2

function1o = function1

@decorators.adapter1
def function1(arg1, arg2):
    '''documentation'''
    return arg1, arg2

function1d = function1

class TestArgumentSpecification(unittest.TestCase):
github ionelmc / python-lazy-object-proxy / tests / test_function.py View on Github external
import imp

import wrapt

from wrapt import six

DECORATORS_CODE = """
import wrapt

@wrapt.decorator
def passthru_decorator(wrapped, instance, args, kwargs):
    return wrapped(*args, **kwargs)
"""

decorators = imp.new_module('decorators')
six.exec_(DECORATORS_CODE, decorators.__dict__, decorators.__dict__)

def function1(arg):
    '''documentation'''
    return arg

function1o = function1

@decorators.passthru_decorator
def function(arg):
    '''documentation'''
    return arg

function1d = function1

class TestNamingFunction(unittest.TestCase):
github ionelmc / python-lazy-object-proxy / tests / test_instancemethod.py View on Github external
import imp

import wrapt

from wrapt import six

DECORATORS_CODE = """
import wrapt

@wrapt.decorator
def passthru_decorator(wrapped, instance, args, kwargs):
    return wrapped(*args, **kwargs)
"""

decorators = imp.new_module('decorators')
six.exec_(DECORATORS_CODE, decorators.__dict__, decorators.__dict__)

class OldClass1():
    def function(self, arg):
        '''documentation'''
        return arg

OldClass1o = OldClass1

class OldClass1():
    @decorators.passthru_decorator
    def function(self, arg):
        '''documentation'''
        return arg

OldClass1d = OldClass1
github ionelmc / python-lazy-object-proxy / tests / test_adapter.py View on Github external
import wrapt

from wrapt import six

DECORATORS_CODE = """
import wrapt

def prototype(arg1, arg2, arg3=None, *args, **kwargs): pass
@wrapt.decorator(adapter=prototype)
def adapter1(wrapped, instance, args, kwargs):
    '''adapter documentation'''
    return wrapped(*args, **kwargs)
"""

decorators = imp.new_module('decorators')
six.exec_(DECORATORS_CODE, decorators.__dict__, decorators.__dict__)

def function1(arg1, arg2):
    '''documentation'''
    return arg1, arg2

function1o = function1

@decorators.adapter1
def function1(arg1, arg2):
    '''documentation'''
    return arg1, arg2

function1d = function1

class TestAdapterAttributes(unittest.TestCase):