On 9/5/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > En Tue, 04 Sep 2007 19:29:11 -0300, Daniel Larsson > <[EMAIL PROTECTED]> escribi�: > > > On 9/5/07, Ferenczi Viktor <[EMAIL PROTECTED]> wrote: > >> > >> > > @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. > > > > > > I have no issue when the decorator is defined in the same module as the > > decorated function, my problem is running doctests on functions using an > > imported decorator. Having to implement the decorator in every source > > module > > isn't very practical. Try splitting your module in two, as I did, and > run > > with -v, and you'll see the problem. > > Looks like a bug. doctest is failing to recognize that the decorated > function belongs to the module being tested. > > A simple patch: In doctest.py, method _from_module, near line 840, you > have these lines: > > elif inspect.getmodule(object) is not None: > return module is inspect.getmodule(object) > > Move them up, just before the line: > > elif inspect.isfunction(object):
Yes, that was basically what I did as well. It makes much more sense to check __module__ first (which is modifiable) rather than func_globals (which obviously isn't). I would have guessed the inspect.getmodule check would cover the isclass test as well (?) This works fine in this case, but I'm not sure whether this breaks in > other circumstances (but I can't think of a case when using > inspect.getmodule() would not be appropiate). > > PS: I can't see any tests for decorated functions (except > @classmethod/@staticmethod) in the library test suite. I'll try to add > some and submit a patch. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list