merge

authorFlorent Cayre <florent.cayre@logilab.fr>
changesetff56f6dbe746
branchdefault
phasepublic
hiddenno
parent revision#87f26f15a66e merge with stable, #202de688e0ea Added tag logilab-database-centos-version-1.9.0-1 for changeset 5397b6fdcb9d
child revision#d5ae6aa3719b [sqlite] drop pysqlite2 support, using plain python sqlite3 module (closes #125083), #1ee780da4556 [sqlite] drop pysqlite2 support, using plain python sqlite3 module (closes #125083), #7db3d7c30c53 default is stable, #8d9520575c0e [sqlgen] Allow arbitrary SQL expression in statements generated by SQLGenerator. Closes #132590
files modified by this revision
__init__.py
test/unittest_db.py
# HG changeset patch
# User Florent Cayre <florent.cayre@logilab.fr>
# Date 1365579600 -7200
# Wed Apr 10 09:40:00 2013 +0200
# Node ID ff56f6dbe746624843621566a972981bd534284e
# Parent 202de688e0ea230e8f21d6c919226e593c916580
# Parent 87f26f15a66eaa6caf9173a315f2b0a05c31b719
merge

diff --git a/__init__.py b/__init__.py
@@ -610,11 +610,11 @@
1                  funcdef = funcdef()
2          except TypeError: # issubclass is quite strict
3              pass
4          assert isinstance(funcdef, FunctionDescr)
5          funcname = funcname or funcdef.name
6 -        self.functions[funcname] = funcdef
7 +        self.functions[funcname.upper()] = funcdef
8 
9      def get_function(self, funcname):
10          try:
11              return self.functions[funcname.upper()]
12          except KeyError:
diff --git a/test/unittest_db.py b/test/unittest_db.py
@@ -111,41 +111,49 @@
13              self.skipTest('python-pgsql is not installed')
14 
15      def testPgsql(self):
16          PREFERED_DRIVERS['postgres'] = ['pyPgSQL.PgSQL']
17          try:
18 +            import pyPgSQL.PgSQL
19 +        except ImportError:
20 +            self.skipTest('python-pygresql is not installed')
21 +        try:
22              cnx = get_connection('postgres',
23                                   self.host, self.db, self.user, self.passwd,
24                                   quiet=1)
25 -        except ImportError:
26 -            self.skipTest('python-pygresql is not installed')
27 +        except pyPgSQL.PgSQL.DatabaseError, ex:
28 +            if str(ex).startswith('could not connect to server:'):
29 +                    self.skipTest('pgsql test requires a specific configuration')
30 +            raise
31 
32      def testMysql(self):
33          PREFERED_DRIVERS['mysql'] = ['MySQLdb']
34          try:
35 -            cnx = get_connection('mysql', self.host, database='', user='root',
36 -                                 quiet=1)
37 +            import MySQLdb
38          except ImportError:
39              self.skipTest('python-mysqldb is not installed')
40 -        except Exception, ex:
41 -            # no mysql running ?
42 -            import MySQLdb
43 -            if isinstance(ex, MySQLdb.OperationalError):
44 -                if ex.args[0] == 1045: # find MysqlDb
45 -                    self.skipTest('mysql test requires a specific configuration')
46 -                elif ex.args[0] != 2003:
47 -                    raise
48 -            raise
49 +        try:
50 +            cnx = get_connection('mysql', self.host, database='', user='root',
51 +                                 quiet=1)
52 +        except  MySQLdb.OperationalError, ex:
53 +            if ex.args[0] == 1045: # find MysqlDb
54 +                self.skipTest('mysql test requires a specific configuration')
55 +            elif ex.args[0] != 2003:
56 +                raise
57 
58      def test_connection_wrap(self):
59          """Tests the connection wrapping"""
60          try:
61 +            import psycopg2
62 +        except ImportError:
63 +            self.skipTest('psycopg2 module not installed')
64 +        try:
65              cnx = get_connection('postgres',
66                                   self.host, self.db, self.user, self.passwd,
67                                   quiet=1)
68 -        except ImportError:
69 -            self.skipTest('postgresql dbapi module not installed')
70 +        except psycopg2.OperationalError, ex:
71 +            self.skipTest('pgsql test requires a specific configuration')
72          self.failIf(isinstance(cnx, PyConnection),
73                      'cnx should *not* be a PyConnection instance')
74          cnx = get_connection('postgres',
75                               self.host, self.db, self.user, self.passwd,
76                               quiet=1, pywrap=True)
@@ -154,15 +162,19 @@
77 
78 
79      def test_cursor_wrap(self):
80          """Tests cursor wrapping"""
81          try:
82 +            import psycopg2
83 +        except ImportError:
84 +            self.skipTest('psycopg2 module not installed')
85 +        try:
86              cnx = get_connection('postgres',
87                                   self.host, self.db, self.user, self.passwd,
88                                   quiet=1, pywrap=True)
89 -        except ImportError:
90 -            self.skipTest('postgresql dbapi module not installed')
91 +        except psycopg2.OperationalError, ex:
92 +            self.skipTest('pgsql test requires a specific configuration')
93          cursor = cnx.cursor()
94          self.failUnless(isinstance(cursor, PyCursor),
95                          'cnx should be a PyCursor instance')
96 
97