[Erp5-report] r24438 - /erp5/trunk/products/ERP5Type/tests/utils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 31 16:07:00 CET 2008


Author: jerome
Date: Fri Oct 31 16:06:54 2008
New Revision: 24438

URL: http://svn.erp5.org?rev=24438&view=rev
Log:
support password in getMySQLArguments (used by runUnitTest --erp5_sql_connection_string=)

Modified:
    erp5/trunk/products/ERP5Type/tests/utils.py

Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=24438&r1=24437&r2=24438&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Fri Oct 31 16:06:54 2008
@@ -195,16 +195,24 @@
 def getMySQLArguments():
   """Returns arguments to pass to mysql by heuristically converting the
   connection string.
-  Only simple cases are coverred for now.
   """
   connection_string = os.environ.get('erp5_sql_connection_string')
   if not connection_string:
     return '-u test test'
-  db, user = connection_string.split()
-  if "@" in db:
+
+  password = ''
+  host = ''
+  db, user = connection_string.split(' ', 1)
+
+  if ' ' in user: # look for user password
+    user, password = user.split()
+    password = '-p%s' % password
+
+  if "@" in db: # look for hostname
     db, host = db.split('@')
-    return "-u %s -h %s %s" % (user, host, db)
-  return '-u %s %s' % (user, db)
+    host = '-h %s' % host
+
+  return '-u %s %s %s %s' % (user, password, host, db)
 
 # decorators
 class reindex(object):




More information about the Erp5-report mailing list