Skipping decorators in unit tests
Terry Reedy
tjreedy at udel.edu
Fri Oct 11 04:17:39 EDT 2013
More information about the Python-list mailing list
Fri Oct 11 04:17:39 EDT 2013
- Previous message (by thread): Skipping decorators in unit tests
- Next message (by thread): Skipping decorators in unit tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/10/2013 11:13 PM, Cameron Simpson wrote: > On 11Oct2013 02:55, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote: >> def undecorate(f): >> """Return the undecorated inner function from function f.""" >> return f.func_closure[0].cell_contents > > Whereas this feels like black magic. Is this portable to any decorated > function? If so, I'd have hoped it was in the stdlib. If not: black magic. > >> And in use: >> >> py> f(100) >> 201 >> py> undecorate(f)(100) >> 200 > > All lovely, provided you can convince me that undecorate() is robust. > (And if you can, I'll certainly be filing it away in my funcutils > module for later use.) It only works if the decorator returns a closure with the original function as the first member (of func_closure). Often true, but not at all a requirement. -- Terry Jan Reedy
- Previous message (by thread): Skipping decorators in unit tests
- Next message (by thread): Skipping decorators in unit tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list