How to peek inside a decorated function

Duncan Booth duncan.booth at invalid.invalid
Sun Feb 15 13:52:12 CET 2009


Steven D'Aprano <steve at pearwood.info> wrote:
> 
> The reason I ask is because I've just spent the weekend battling with
> doctests of decorated functions, and discovering that without
> functools.wraps() all my doctests weren't being called. I'm wondering
> whether it would be a good idea for doctest to auto-detect tests in
> closures.
> 
> This is not needed if you call wraps() appropriately, but you might not
> always do that.
> 

I don't think it is a good idea to call the wrapped doctests automatically, 
but I do think it might be a good idea to detect and warn about anything 
which looks like it is a wrapper where the wrapped function includes a 
doctest and the wrapper doesn't.


-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list