Decorator cllass hides docstring from doctest?

Berthold Höllmann berthold at despammed.com
Thu Sep 21 14:57:43 CEST 2006


Saving the following code to a file and running the code through
python does not give the expected error. disableling the "@decor" line
leads to the expected error message. Is this a bug or an overseen
feature?


--- snip dectest.py ---
class decor(object):
    def __init__(self, f):
        self.f = f
    def __call__(self, *args, **kw):
        return self.f(*args, **kw)

@decor
def f(a, b):
    """
    >>> f(1,2)
    False
    >>> f(2,2)
    False
    """
    return a == b

def _test():
    import doctest
    doctest.testmod()

if __name__ == "__main__":
    _test()
--- snip dectest.py ---

Our Python is:

Python 2.4.2 (#1, Dec  5 2005, 10:13:23) 
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.


Thanks
Berthold
-- 
                            __   Address:
                         G /  \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 35       P.O.Box 111606
fax  : +49-40-36149-7320   \__/   D-20459 Hamburg    D-20416 Hamburg




More information about the Python-list mailing list