On Wed, Jan 22, 2014 at 4:27 PM, Saint Germain <[email protected]> wrote:
> On Mon, 20 Jan 2014 00:10:55 -0500, Olemis Lang <[email protected]> > wrote : > > > > > > > Currently on trunk I got a lot of similar mistakes when running the > > > test on bloodhound_search like this one: > > > > > > ====================================================================== > > > ERROR: test_admin_granted_in_product_should_not_have_access > > > (bhsearch.tests.security.MultiProductSecurityTestCase) > > > ---------------------------------------------------------------------- > > > Traceback (most recent call last): > > [...] > > > OperationalError: duplicate column name: product > > > > > > Does that ring a bell to someone ? > > > > > > > It looks ok to me , see http://pastebin.com/kxvua4TU > > > > Hello ! > > I found the problem. > > In tests/env.py we have: > from sqlite3 import OperationalError > > And in trac/trac/db/sqlite_backend.py we have: > try: > import pysqlite2.dbapi2 as sqlite > have_pysqlite = 2 > except ImportError: > try: > import sqlite3 as sqlite > have_pysqlite = 2 > except ImportError: > have_pysqlite = 0 > > As I have both sqlite3 and python-pysqlite2 installed, I got a mismatch > when an exception is raised: > sqlite3.OperationalError != pysqlite2.dbapi2.OperationalError > > And the tests cannot run. > > If I deinstall python-pysqlite2, then the tests can run. > > Do you think it is necessary to fix this ? > In test files we can reproduce the same logic as in the sqlite_backend > to correctly import sqlite. > > Best regards, > > Trac provides an API for working with database exceptions. I believe the following patch would be the proper way to handle it. Would you kindly test it in your environment? diff --git a/bloodhound_multiproduct/tests/env.py b/bloodhound_multiproduct/tests/env.py index 30910e4..98cd1bc 100644 --- a/bloodhound_multiproduct/tests/env.py +++ b/bloodhound_multiproduct/tests/env.py @@ -23,7 +23,6 @@ from inspect import stack import os.path import shutil import tempfile -from sqlite3 import OperationalError from tests import unittest from types import MethodType @@ -230,7 +229,7 @@ class MultiproductTestCase(unittest.TestCase): mpsystem = MultiProductSystem(env) try: mpsystem.upgrade_environment(env.db_transaction) - except OperationalError: + except env.db_exc.OperationalError: # Database is upgraded, but database version was deleted. # Complete the upgrade by inserting default product. mpsystem._insert_default_product(env.db_transaction)
