On 10/10/2013 10:00 AM, Gilles Lenfant wrote: To add to the other two responses so far...
(explaining the title) : my app has functions and methods (and maybe classes in the future) that are decorated by decorators provided by the standard library or 3rd party packages. But I need to test "undecorated" functions and methods in my unit tests, preferably without adding "special stuffs" in my target tested modules.
Let's assume that the decorator wraps the function in a way that the wrapper has a reference to the original function, so it does not disappear.
Can someone point out good practices or dedicated tools that "remove temporarily" the decorations.
The easiest thing would be to have the decorator add the original function as an attribute .wrapped to the wrapper. Then test foo.wrapped. If you do not like this 'special stuff', then you would have to introspect the wrapper to access the wrapped function. How to do that depends on the wrapper.
-- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list