Coverage removes DecoratorTools's tracing function · Issue #125 · nedbat/coveragepy (original) (raw)

Originally reported by Bobby Impollonia (Bitbucket: bobbyi, GitHub: bobbyi)


The PEAK DecoratorTools library (http://pypi.python.org/pypi/DecoratorTools) uses a tracing function to allow the use of decorators for older versions of Python.

In the past, this library conflicted with coverage because DecoratorTools would add its own tracing function and in the process remove coverage's, causing coverage to believe that no lines were executed. The current (development) version fixes this by restoring any existing tracing functions.

However, when using the current DecoratorTools library with coverage, I run into failures because coverage seems to be removing DecoratorTools's tracing function somehow: when (and only when) using coverage, functions that should be decorated by DecoratorTools act as if they do not have the decorator applied (as if DecoratorTools tracing function were removed).

I have attached a test program called dec.py. With that file in the current directory, you can reproduce the problem as follows (I am using Python 2.6):

virtualenv --no-site-packages myenv
. myenv/bin/activate
pip install ez_setup coverage distribute==0.6.14
pip install http://svn.eby-sarna.com/DecoratorTools.tar.gz?view=tar
python ./dec.py # this succeeds
coverage run ./dec.py # this throws the exception

The exception is "'MyClass' object has no attribute 'name'" which indicates that our classmethod decorator has been ignored and the method is instead being treated as an instance method.

This issue causes coverage to fail when used with TurboGears applications since TG relies on PEAK Rules which relies on DecoratorTools.

Running with --timid still works, but ideally should no longer be needed now that DecoratorTools has been updated to restore coverage's tracing function.