[PEAK] Conflict between PEAK and coverage.py

Bobby Impollonia bobbyi at gmail.com
Sat Mar 12 18:19:34 EST 2011

I am trying to measure code coverage for a project using coverage.py.
The project relies on DecoratorTools and PEAK-Rules via Turbogears.

With DecoratorTools 1.8, the coverage report always comes back as 0%
due to a known problem where DecoratorTools removes coverage's tracing
function. This is fixed in the development version of DecoratorTools
which uses sys.gettrace() on Python 2.6+ to find and restore existing
tracing functions.

However, with the current development versions of DecoratorTools and
PEAK-Rules, I now receive an error importing PEAK-Rules when (and only
when) running under coverage.py.

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"

You can reproduce the problem with the following steps using Python 2.6:
virtualenv --no-site-packages myenv
cd myenv
. bin/activate
pip install ez_setup coverage distribute==0.6.14
pip install http://svn.eby-sarna.com/DecoratorTools.tar.gz?view=tar
pip install http://svn.eby-sarna.com/PEAK-Rules.tar.gz?view=tar
echo '#!/usr/bin/env python' > mytest.py
echo 'import peak.rules' >> mytest.py
chmod +x mytest.py
./mytest.py # this succeeds
coverage run ./mytest.py # this throws the exception

More information about the PEAK mailing list