Skipping decorators in unit tests
Terry Reedy
tjreedy at udel.edu
Fri Oct 11 04:23:57 EDT 2013
On 10/11/2013 12:36 AM, Steven D'Aprano wrote:
> I also like Terry Reedy's suggestion of having the decorator
> automatically add the unwrapped function to the wrapped function as an
> attribute:
>
> def decorate(func):
> @functools.wraps(func)
> def inner(arg):
> blah blah
> inner._unwrapped = func # make it public if you prefer
> return inner
>
> which makes it all nice and clean and above board. (I seem to recall a
> proposal to have functools.wraps do this automatically...)
The explicit attribute can also be set by class rather than closure
based decorators.
--
Terry Jan Reedy
More information about the Python-list
mailing list