P.J. Eby | 18 Mar 2011 19:59
Gravatar

Re: Conflict between PEAK and coverage.py

At 03:19 PM 3/12/2011 -0800, Bobby Impollonia wrote:
>The error is:
>TypeError: unbound method make_decorator() must be called with Method
>instance as first argument (got str instance instead)
>
>It originates from line 296 of peak.rules.core:
>when = Method.make_decorator(
>    "when", "Extend a generic function with a new action"
>)

The real error here is occurring earlier, when make_decorator isn't 
getting made into a classmethod.  So, it would appear that something 
in coverage's trace function is disabling DecoratorTools' trace 
function, or at any rate stopping it from getting called.

>coverage run ./mytest.py # this throws the exception

Have you tried the --timid option?  Coverage's internal docs suggest 
that this is required when working with DecoratorTools.
Bobby Impollonia | 22 Mar 2011 22:13
Picon
Gravatar

Re: Conflict between PEAK and coverage.py

On Fri, Mar 18, 2011 at 11:59 AM, P.J. Eby <pje@...> wrote:
> The real error here is occurring earlier, when make_decorator isn't getting
> made into a classmethod.

Thanks for explanation. You are right as I can recreate the problem
without Peak Rules using the following test program:
from peak.util.decorators import decorate

class MyClass(object):
    decorate(classmethod)
    def myclassmethod(cls):
        return cls.__name__

if __name__ == '__main__':
    print MyClass().myclassmethod() # throws exception under coverage

> So, it would appear that something in coverage's
> trace function is disabling DecoratorTools' trace function, or at any rate
> stopping it from getting called.

So is this likely a bug in coverage?

> Have you tried the --timid option?  Coverage's internal docs suggest that
> this is required when working with DecoratorTools.

It works correctly with --timid. It's somewhat inconvenient because it
makes the tests run several times slower and nose's coverage plugin
doesn't expose that option.

Gmane