> > @functools.wraps(f)
> > Pass the function to be wrapped by the decorator to the wraps function.
> Ooops, right. That doesn't change the fact that decorated functions get
> hidden from doctest though.

Run my test script (one file) with the -v (verbose) option. Without the -v 
option it does not show output. This fact is documented in the Python manual 
at the doctest module.

--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 
import functools

def simplelog(f):
    @functools.wraps(f)
    def new_f(*args, **kwds):
        print "Wrapper calling func"
        return f(*args, **kwds)
    return new_f

@simplelog
def test():
    """
    >>> test()
    Wrapper calling func
    'works!'
    """
    return 'works!'

def fn():
    """
    >>> fn()
    'ok'
    """
    return 'ok'

if __name__ == '__main__':
    import doctest
    doctest.testmod()
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 

Regard, Viktor
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to