changeset 412:3f566f30d14d

hmm, test only works called from mysqlpy
author catherine@DellZilla
date Thu, 15 Oct 2009 20:35:52 -0400
parents 83185d382d10
children 7e3910c7bcb7
files sqlpython/mysqlpy.py sqlpython/sqlpython.py
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/mysqlpy.py	Thu Oct 15 19:39:14 2009 -0400
+++ b/sqlpython/mysqlpy.py	Thu Oct 15 20:35:52 2009 -0400
@@ -210,12 +210,13 @@
     for arg in ('-t', '--test'):
         if arg in testfiles:
             testfiles.remove(arg)
+            sys.argv.remove(arg)
             mysqlpy.testfiles = testfiles
             if not testfiles:
                 print 'No test file specified to run against!'
                 sys.exit()
     if hasattr(mysqlpy, 'testfiles'):
-        sys.argv = [sys.argv[0]]
+        sys.argv = [sys.argv[0]]  # the --test argument upsets unittest.main()        
         unittest.main()
     else:
         run()
\ No newline at end of file
--- a/sqlpython/sqlpython.py	Thu Oct 15 19:39:14 2009 -0400
+++ b/sqlpython/sqlpython.py	Thu Oct 15 20:35:52 2009 -0400
@@ -121,9 +121,15 @@
     postgresql_connect_parser = (legal_sql_word('db_name') + 
                                  pyparsing.Optional(legal_sql_word('username')))
           
-    def connect_url(self, arg, opts):
-        rdbms = opts.rdbms or self.default_rdbms
-        
+    def connect_url(self, arg, opts):               
+        if opts.oracle:
+            rdbms = 'oracle'
+        elif opts.postgres:
+            rdbms = 'postgres'
+        elif opts.mysql:
+            rdbms = 'mysql'
+        else:
+            rdbms = self.default_rdbms
         mode = 0
         host = None
         port = None
@@ -210,6 +216,7 @@
             url = self.connect_url(arg, opts)
             connect_info = self.url_connect(url)
         except Exception, e:
+            self.perror(str(e))
             self.perror(r'URL connection format: rdbms://username:password@host/database')
             return
         if opts.add or (self.connection_number is None):