Re: Doctests and decorated methods don't get along

2010-02-09 Thread Diez B. Roggisch
Am 06.02.10 12:48, schrieb Steven D'Aprano: It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): """Emulate built-in staticmethod descriptor.""" def __init__(self, f): se

Re: Doctests and decorated methods don't get along

2010-02-06 Thread Terry Reedy
On 2/6/2010 7:51 PM, Steven D'Aprano wrote: I have found an existing report for this issue: http://bugs.python.org/issue4037 The original poster's suggested fix was on the right track, but not complete. I've added a patch which works according to my tests. Since this report is currently unass

Re: Doctests and decorated methods don't get along

2010-02-06 Thread Steven D'Aprano
On Sat, 06 Feb 2010 14:39:00 -0500, Terry Reedy wrote: > On 2/6/2010 6:48 AM, Steven D'Aprano wrote: >> It seems that doctest doesn't discover or execute doctests in methods >> which have been decorated [by method descriptors]. [...] >> This looks like bug to me. Have I missed anything? > > I

Re: Doctests and decorated methods don't get along

2010-02-06 Thread Steven D'Aprano
On Sat, 06 Feb 2010 14:39:00 -0500, Terry Reedy wrote: > On 2/6/2010 6:48 AM, Steven D'Aprano wrote: >> It seems that doctest doesn't discover or execute doctests in methods >> which have been decorated. [...] > Doctest has to scan the dict, so it does not see the attribute-lookup > result. Aha

Re: Doctests and decorated methods don't get along

2010-02-06 Thread Steven D'Aprano
On Sat, 06 Feb 2010 14:00:28 -0500, John Posner wrote: > On 2/6/2010 6:48 AM, Steven D'Aprano wrote: >> class MyStaticMethod(object): >> """Emulate built-in staticmethod descriptor.""" >> def __init__(self, f): >> self.f = f >> def __get__(self, obj, objtype=None): >>

Re: Doctests and decorated methods don't get along

2010-02-06 Thread Terry Reedy
On 2/6/2010 6:48 AM, Steven D'Aprano wrote: It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): """Emulate built-in staticmethod descriptor.""" def __init__(self, f): se

Re: Doctests and decorated methods don't get along

2010-02-06 Thread John Posner
On 2/6/2010 6:48 AM, Steven D'Aprano wrote: class MyStaticMethod(object): """Emulate built-in staticmethod descriptor.""" def __init__(self, f): self.f = f def __get__(self, obj, objtype=None): return self.f How about using a function, instead of a class, to imp

Doctests and decorated methods don't get along

2010-02-06 Thread Steven D'Aprano
It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): """Emulate built-in staticmethod descriptor.""" def __init__(self, f): self.f = f def __get__(self, obj, objtype=None