Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2375 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Identity/Visit unit tests error because of missing table tg_visit

Reported by: chrisz Owned by:
Priority: normal Milestone: 1.1
Component: TurboGears Version: 1.1rc1
Severity: normal Keywords:
Cc:

Description

When I run nosetests or python setup.py test for TG 1.1rc1 and have SA 0.4.8 installed, then tests in test_visit fail with OperationalError: no such table: tg_visit.

When I run only nosetests turbogears.identity.tests.test_visit or have SA 0.5.0 installed, then I do not get failing tests.

Change History

comment:1 Changed 10 years ago by Chris Arndt

  • Keywords needs patch, visit, tests added
  • Milestone changed from 1.x to 1.1

I can only reproduce this (on OS X 10.4, Python 2.5) when I run the whole test suite from the root of the branch, i.e:

/branches/1.1$ python setup.py test

or

/branches/1.1$ nosetest [-v]

not if I run the identity test directly (with nosetests [-v] turbogears/identity/tests).

Also, the first test that fails for me is turbogears/identity/tests/test_identity/test_anonymous_browsing not the visit tests. This might suggest that this is a threading issue. However, the tests fail at the same spot on a Ubuntu Hardy (Python 2.5) System.

Does this stem from the same cause as #1929?

comment:2 Changed 10 years ago by Chris Arndt

  • Summary changed from Unit tests missing table tg_visit to Identity/Visit unit tests error because oof missing table tg_visit

comment:3 Changed 10 years ago by Chris Arndt

  • Summary changed from Identity/Visit unit tests error because oof missing table tg_visit to Identity/Visit unit tests error because of missing table tg_visit

comment:4 Changed 10 years ago by chrisz

That's exactly what I am observing, i.e. we can reproduce this on 3 different platforms (OS X, Ubuntu, Win). When I run the identity tests alone, I do not get this error. And you're right, the first failing test is turbogears/identity/tests/test_identity/test_anonymous_browsing. But all other identity and visit tests fail because of the same problem. You're right, #1929 may have been a similar issue. The strange thing here is that it works with SA > 0.5.

comment:5 Changed 10 years ago by kskuhlman

  • Status changed from new to closed
  • Keywords needs patch, visit, tests removed
  • Resolution set to fixed

There was some initialization being done at import time in turbogears.tests.test_paginate that was interacting with the identity tests.

I moved it to setup_module in r6699 so that it's properly isolated.

comment:6 Changed 10 years ago by Chris Arndt

Aaargh! And I was bumping my head against the wall because I couldn't figure out why my sqlobject dburi in test.cfg wasn't used. I set it to create a local file but no file was created.

I think Roger Demetrescu owes us a beer! ;) I just lost half a day trying to track down what seemed like a SQLAlchemy bug. :(

But it isn't really his fault. The whole database configuration system is a mess (see #1813).

Also, it is too easy to mess up the global configuration in the tests, which makes it very hard to ensure that all test run in real isolation.

comment:7 Changed 10 years ago by kskuhlman

Yeah, these "test works when run standalone, but fails when run with others" bugs are almost always test isolation issues. I usually track them down by gradually adding in more tests until the problem pops up.

This time, though, I downgraded nose to 0.9.3 first. At that version, the paginate tests failed & the identity ones worked fine, which highlighted the issue quite nicely.

Something changed in nose's test loader between .9 & .10 that makes these bugs harder to track down. So I think Jason Pellerin owes us a beer, too. :-)

I'd be happy to pay off both Roger & Jason's debts. Send me an address & your favorite beer & I'll get it shipped out!

comment:8 Changed 10 years ago by chrisz

Just tried to check in a similar fix when I got a merge conflict because Ken was quicker. Should have looked into my email ;-)

As Ken already mentioned, the problem was that the test_paginate module called sqlalchemy_cleanup() at import time, which called metadata.clear(). This removed the visit table from the metadata, but SA < 0.5 only creates tables when there is an entry in metadata (the table_iterator method there always builds the intersection with metadata.tables).

Note: See TracTickets for help on using tickets.