merge with stable

authorPierre-Yves David <pierre-yves.david@logilab.fr>
changeset87f26f15a66e
branchdefault
phasepublic
hiddenno
parent revision#df5efe92aac5 merge with more recent stable changes, #d9a785c7ac93 Added tag logilab-database-debian-version-1.9.0-1 for changeset 89a6e45cf45e
child revision#ff56f6dbe746 merge, #c6279447b722 [sqlgen] Allow to unprotect some parameters during the creation of an SQL INSERT query, #02d1e51edf66 sqlite: drop pysqlite2 support, using plain python sqlite3 module (closes #125083), #54a7e5ad624f Add a SQL_CONVERTERS dict to allow possible conversions to SQL for specific types.
files modified by this revision
__init__.py
test/unittest_db.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1363882050 -3600
# Thu Mar 21 17:07:30 2013 +0100
# Node ID 87f26f15a66eaa6caf9173a315f2b0a05c31b719
# Parent d9a785c7ac93783a287478477051733ee8e11e86
# Parent df5efe92aac5282bc59f396c914d26eb28aca464
merge with stable

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