[Neo-report] r2806 jm - /trunk/neo/tests/functional/__init__.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Aug 25 16:58:27 CEST 2011


Author: jm
Date: Thu Aug 25 16:58:27 2011
New Revision: 2806

Log:
tests: do not setup MySQL db if only BTree will be used

Modified:
    trunk/neo/tests/functional/__init__.py

Modified: trunk/neo/tests/functional/__init__.py
==============================================================================
--- trunk/neo/tests/functional/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/functional/__init__.py [iso-8859-1] Thu Aug 25 16:58:27 2011
@@ -238,6 +238,7 @@ class NEOCluster(object):
         ):
         if not adapter:
             adapter = 'MySQL'
+        self.adapter = adapter
         self.zodb_storage_list = []
         self.cleanup_on_delete = cleanup_on_delete
         self.verbose = verbose
@@ -324,17 +325,22 @@ class NEOCluster(object):
         return MySQLdb.Connect(**connect_arg_dict)
 
     def setupDB(self):
-        sql_connection = self.__getSuperSQLConnection()
-        cursor = sql_connection.cursor()
-        for database in self.db_list:
-            cursor.execute('DROP DATABASE IF EXISTS `%s`' % (database, ))
-            cursor.execute('CREATE DATABASE `%s`' % (database, ))
-            cursor.execute('GRANT ALL ON `%s`.* TO "%s"@"localhost" '\
-                           'IDENTIFIED BY "%s"' % (database, self.db_user,
-                           self.db_password))
-        cursor.close()
-        sql_connection.commit()
-        sql_connection.close()
+        if self.adapter == 'MySQL':
+            sql_connection = self.__getSuperSQLConnection()
+            cursor = sql_connection.cursor()
+            for database in self.db_list:
+                try:
+                    cursor.execute('DROP DATABASE `%s`' % database)
+                except MySQLdb.OperationalError, (code, _):
+                    if code != MySQLdb.constants.ER.DB_DROP_EXISTS:
+                        raise
+                cursor.execute('CREATE DATABASE `%s`' % database)
+                cursor.execute('GRANT ALL ON `%s`.* TO "%s"@"localhost" '
+                               'IDENTIFIED BY "%s"' % (database, self.db_user,
+                               self.db_password))
+            cursor.close()
+            sql_connection.commit()
+            sql_connection.close()
 
     def switchTables(self, database):
         sql_connection = self.__getSuperSQLConnection()




More information about the Neo-report mailing list