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'''
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):
from wrapt import six OBJECTS_CODE = """ class TargetBaseClass(object): "documentation" class Target(TargetBaseClass): "documentation" def target(): "documentation" pass """ objects = imp.new_module('objects') six.exec_(OBJECTS_CODE, objects.__dict__, objects.__dict__) class TestAttributeAccess(unittest.TestCase): def test_attributes(self): def function1(*args, **kwargs): return args, kwargs function2 = wrapt.ObjectProxy(function1) self.assertEqual(function2.__wrapped__, function1) def test_get_wrapped(self): def function1(*args, **kwargs): return args, kwargs function2 = wrapt.ObjectProxy(function1)
from wrapt import six OBJECTS_CODE = """ class TargetBaseClass(object): "documentation" class Target(TargetBaseClass): "documentation" def target(): "documentation" pass """ objects = imp.new_module('objects') six.exec_(OBJECTS_CODE, objects.__dict__, objects.__dict__) class TestAttributeAccess(unittest.TestCase): def test_attributes(self): def function1(*args, **kwargs): return args, kwargs function2 = wrapt.ObjectProxy(function1) self.assertEqual(function2.__wrapped__, function1) def test_get_wrapped(self): def function1(*args, **kwargs): return args, kwargs