Problem with coverage and sqlalchemy declarative synonym?

7 views
Skip to first unread message

Doug Latornell

unread,
Sep 16, 2008, 7:25:15 PM9/16/08
to sqlalchemy
Over on the TurboGears list a TG2 user pointed out a problem that
arises when nosetests --with-coverage is run on a project with a
sqlalchemy identity model: http://groups.google.com/group/turbogears/t/7fd3639a5a4d4b8c

I dug into it and have reproduced the problem outside of TurboGears 2
and without nose: http://paste.turbogears.org/paste/7051

I've also shown that the problem isn't there for a plain Python
property (in contrast to a sqlalchemy
synonym): http://paste.turbogears.org/paste/7052

So, it looks like a problem maybe with the metaclass that sqlalchemy
uses to build properties, or with coverage not understanding what that
metaclass produces, or something. Or is there something else I'm
missing?

Doug

jason kirtland

unread,
Sep 16, 2008, 7:52:07 PM9/16/08
to sqlal...@googlegroups.com

Seems to be a problem in coverage. This narrows down a problem that was
first seen only when running inside Bitten.

$ cat c.py
def foo(somearg):
class Bar(object):
def __getattr__(self, attribute):
return getattr(somearg, attribute)

assert 'somearg' not in Bar.__dict__

foo('hi')

$ python c.py
$ coverage -e
$ coverage -x c.py
Traceback (most recent call last):
File "/Users/jek/bin/coverage", line 8, in <module>
load_entry_point('coverage==2.80', 'console_scripts', 'coverage')()
File "build/bdist.macosx-10.5-i386/egg/coverage.py", line 978, in main
File "build/bdist.macosx-10.5-i386/egg/coverage.py", line 398, in
command_line
File "c.py", line 8, in <module>
foo('hi')
File "c.py", line 6, in foo
assert 'somearg' not in Bar.__dict__
AssertionError

Michael Bayer

unread,
Sep 16, 2008, 7:55:12 PM9/16/08
to sqlal...@googlegroups.com

I've seen this identical issue with Bitten, and its not a SQLAlchemy
one.

Here's the ticket: http://www.sqlalchemy.org/trac/ticket/1138

Replace your test case with this script:

def foo(somearg):
class Bar(object):
def __getattr__(self, attribute):
return getattr(somearg, attribute)

assert 'somearg' not in Bar.__dict__

foo('hi')

I just ran it with the "coverage.py" that we have in SQLAlchemy and
the bug reproduces.

Doug Latornell

unread,
Sep 16, 2008, 8:22:10 PM9/16/08
to sqlalchemy
Thanks for the quick replies, Jason and Michael, and for the very
succinct test case. I will try to raise this with Ned Bachelor over
at http://nedbatchelder.com/code/modules/coverage.html

Doug

Doug Latornell

unread,
Sep 18, 2008, 4:08:34 PM9/18/08
to sqlalchemy
With some help from Ned Batchelder I was able to confirm that this is
a Python bug: http://bugs.python.org/issue1569356 that has been fixed
since the 2.5.2 release. Ned confirmed that the fix is included in
Python 2.6a3.

Doug

On Sep 16, 5:22 pm, Doug Latornell <djlatorn...@gmail.com> wrote:
> Thanks for the quick replies, Jason and Michael, and for the very
> succinct test case.  I will try to raise this with Ned Bachelor over
> athttp://nedbatchelder.com/code/modules/coverage.html

Michael Bayer

unread,
Sep 19, 2008, 9:54:41 AM9/19/08
to sqlal...@googlegroups.com

On Sep 18, 2008, at 4:08 PM, Doug Latornell wrote:

>
> With some help from Ned Batchelder I was able to confirm that this is
> a Python bug: http://bugs.python.org/issue1569356 that has been fixed
> since the 2.5.2 release. Ned confirmed that the fix is included in
> Python 2.6a3.


well thats....peachy. I suppose we might have to find a way to work
around it in SQLA (changing names in that area I think).


Reply all
Reply to author
Forward
0 new messages