nosetests failed on a quickstart project with identity.

10 views
Skip to first unread message

Stef

unread,
Sep 13, 2008, 12:30:28 PM9/13/08
to turbo...@googlegroups.com
Hello

First of all, I want to say a big thank to all of you for developing this amazing framework.

I've decided to take a look at TG2 to see all the new features since TG1.
I've just made a fresh install  and create a project named 'tgtest' from paster quickstart and answered 'yes' to identity question.

As I want to use unit testing I've tried nosetests. If I'm simply running "nosetests" all tests pass, but if i'm trying the command "nosetests --with-coverage --cover-package=tgtest" it fails with one error and give me this traceback :

> nosetests --with-coverage --cover-package=tgtest
E
======================================================================
ERROR: Failure: AttributeError ('property' object has no attribute '_User__encrypt_password')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/local/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/loader.py", line 364, in loadTestsFromName
    addr.filename, addr.module)
  File "/opt/local/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/opt/local/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py", line 84, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Developer/stef/work/perso/tgtest/tgtest/tests/__init__.py", line 33, in <module>
    cmd.run([test_file])
  File "/opt/local/lib/python2.5/site-packages/PasteScript-1.6.3-py2.5.egg/paste/script/appinstall.py", line 68, in run
    return super(AbstractInstallCommand, self).run(new_args)
  File "/opt/local/lib/python2.5/site-packages/PasteScript-1.6.3-py2.5.egg/paste/script/command.py", line 213, in run
    result = self.command()
  File "/opt/local/lib/python2.5/site-packages/PasteScript-1.6.3-py2.5.egg/paste/script/appinstall.py", line 456, in command
    self, config_file, section, self.sysconfig_install_vars(installer))
  File "/opt/local/lib/python2.5/site-packages/PasteScript-1.6.3-py2.5.egg/paste/script/appinstall.py", line 600, in setup_config
    mod.setup_config(command, filename, section, vars)
  File "/Developer/stef/work/perso/tgtest/tgtest/websetup.py", line 21, in setup_config
    u = model.User()
  File "<string>", line 4, in __init__
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/attributes.py", line 815, in initialize_instance
    fn(self, instance, args, kwargs)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/mapper.py", line 1678, in _event_on_init
    instrumenting_mapper.compile()
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/mapper.py", line 369, in compile
    mapper.__initialize_properties()
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/mapper.py", line 390, in __initialize_properties
    prop.init(key, self)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/interfaces.py", line 384, in init
    self.do_init()
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/properties.py", line 207, in do_init
    None, None, False, comparator_callable, proxy_property=self.descriptor)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/strategies.py", line 45, in _register_attribute
    active_history=active_history
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 87, in register_attribute
    return attributes.register_attribute(class_, key, *args, **kwargs)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/attributes.py", line 1460, in register_attribute
    descriptor = proxy_type(key, proxy_property, comparator, parententity)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/attributes.py", line 156, in __init__
    self.descriptor = self.user_prop = descriptor
  File "/Developer/stef/work/perso/tgtest/tgtest/model/identity.py", line 102, in _set_password
    self._password = self.__encrypt_password(algorithm, password)
  File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc1-py2.5.egg/sqlalchemy/orm/attributes.py", line 184, in __getattr__
    return getattr(descriptor, attribute)
AttributeError: 'property' object has no attribute '_User__encrypt_password'

Name                        Stmts   Exec  Cover   Missing
---------------------------------------------------------
tgtest                          0      0   100%   
tgtest.config                   0      0   100%   
tgtest.config.app_cfg          21     21   100%   
tgtest.config.environment       2      2   100%   
tgtest.config.middleware        6      6   100%   
tgtest.controllers              0      0   100%   
tgtest.lib                      0      0   100%   
tgtest.lib.app_globals          3      3   100%   
tgtest.lib.helpers              1      1   100%   
tgtest.model                   10     10   100%   
tgtest.model.identity          68     43    63%   50, 72, 77-80, 87, 94, 107, 116-149, 154-158
tgtest.templates                0      0   100%   
tgtest.websetup                38     13    34%   22-55
---------------------------------------------------------
TOTAL                         149     99    66%   
----------------------------------------------------------------------
Ran 1 test in 0.876s

FAILED (errors=1)





Am I doing something wrong?
It is a fresh install of python-2.5 with no previous turbogears installation.
I've upgraded SQLAlchemy from 0.5.0-beta3 to 0.5.0rc1 and tg.devtools from 1.9.7a4 to 1.9.7a4dev-r5288 to see if the problem could be resolved by simply upgrading.

Stef.

Doug Latornell

unread,
Sep 15, 2008, 1:03:01 PM9/15/08
to TurboGears
I can reproduce what you are seeing Stef. I've got a clean 1.9.7a4
virtualenv with coverage, WebTest, and BeautifulSoup added manually
via easy_install.

It's interesting that the problem only arises when nose is run with
the coverage plug-in.

I'll try to get some time later today to dig into this and reply here
with what (if anything) I find.

Doug

Doug Latornell

unread,
Sep 15, 2008, 9:17:42 PM9/15/08
to TurboGears
I'm stumped.

There's something weird happening to attribute calls in
identity.py:User._set_password() when nosetests --with-coverage is
used. But the weirdness goes away if you don't ask for coverage.
Attribute calls are being transferred on to property from the synonym
call. There's nothing special about __encrypt_password(); you can get
the same weirdness by changing:
self._password = self.__encrypt_password(algorithm, password)
to
self._password = password.upper()

Doug

Doug Latornell

unread,
Sep 16, 2008, 12:42:06 AM9/16/08
to TurboGears
I've reproduced this problem outside of TG2: http://paste.turbogears.org/paste/6992

Looks to me like it's an issue in coverage, nose, or sqlalchemy,
especially since it only appears when --with-coverage is used.

Doug

Doug Latornell

unread,
Sep 16, 2008, 1:12:12 PM9/16/08
to TurboGears
http://paste.turbogears.org/paste/7051 isolates the problem to an
interaction between sqlalchemy and coverage - takes nose out of the
picture.

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

Doug

Jorge Vargas

unread,
Sep 16, 2008, 2:33:57 PM9/16/08
to turbo...@googlegroups.com
Awesome debugging on your part. I think we are almost certain at this
point that this is an issue with SQLAlchemy's metaclass used to build
the properties (or coverage not understanding them), I'll suggest you
cc the sa mailing list so Michael Bayer will take a look at it.

Doug Latornell

unread,
Sep 16, 2008, 8:28:30 PM9/16/08
to TurboGears
Thanks, Jorge.

I took this to the sqlalchemy list
http://groups.google.com/group/sqlalchemy/browse_thread/thread/66eea947fdb79b81#
and got a quick reply that it's not an sa issue, and that it has also
been seen with Bitten. I also got an even simpler test case that
isolates the problem to coverage: http://paste.turbogears.org/paste/7081

So, I guess the next stop is http://nedbatchelder.com/code/modules/coverage.html

Doug

On Sep 16, 11:33 am, "Jorge Vargas" <jorge.var...@gmail.com> wrote:
> Awesome debugging on your part. I think we are almost certain at this
> point that this is an issue with SQLAlchemy's metaclass used to build
> the properties (or coverage not understanding them), I'll suggest you
> cc the sa mailing list so Michael Bayer will take a look at it.
>
> On Tue, Sep 16, 2008 at 11:12 AM, Doug Latornell <djlatorn...@gmail.com> wrote:
>
> >http://paste.turbogears.org/paste/7051isolates the problem to an
> > interaction between sqlalchemy and coverage - takes nose out of the
> > picture.
>
> >http://paste.turbogears.org/paste/7052shows that the problem isn't

Doug Latornell

unread,
Sep 18, 2008, 4:07:28 PM9/18/08
to TurboGears
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:28 pm, Doug Latornell <djlatorn...@gmail.com> wrote:
> Thanks, Jorge.
>
> I took this to the sqlalchemy listhttp://groups.google.com/group/sqlalchemy/browse_thread/thread/66eea9...
> and got a quick reply that it's not an sa issue, and that it has also
> been seen with Bitten.  I also got an even simpler test case that
> isolates the problem to coverage:http://paste.turbogears.org/paste/7081
>
> So, I guess the next stop ishttp://nedbatchelder.com/code/modules/coverage.html
>
> Doug
>
> On Sep 16, 11:33 am, "Jorge Vargas" <jorge.var...@gmail.com> wrote:
>
> > Awesome debugging on your part. I think we are almost certain at this
> > point that this is an issue with SQLAlchemy's metaclass used to build
> > the properties (or coverage not understanding them), I'll suggest you
> > cc the sa mailing list so Michael Bayer will take a look at it.
>
> > On Tue, Sep 16, 2008 at 11:12 AM, Doug Latornell <djlatorn...@gmail.com> wrote:
>
> > >http://paste.turbogears.org/paste/7051isolatesthe problem to an
> > > interaction between sqlalchemy and coverage - takes nose out of the
> > > picture.
>
> > >http://paste.turbogears.org/paste/7052showsthat the problem isn't
> ...
>
> read more »

Barry Hart

unread,
Sep 18, 2008, 9:32:07 PM9/18/08
to turbo...@googlegroups.com
I've had all sorts of problems with Nose -- it seems to do tons of tricky things that start to fall apart on more complex code bases. It interferes with namespace packages, it changes the current directory when it runs your tests, one time it caused every one of my tests to fail because we added a module-level variable named __metadata__ to one of our files, aaagggghhh.

I finally gave up and wrote my own unittest loader plus some monkey patches. It supports the key features of Nose (for me) and doesn't cause weird problems.

Barry

Reply all
Reply to author
Forward
0 new messages