# HG changeset patch # User catherine@DellZilla # Date 1255631432 14400 # Node ID 80413ef3699a94d4a691ca897b38b69559a6471d # Parent 188c86d4a11ebf6ff39fdd88305a82adecf6a60d going to take optparse out of __main__ diff -r 188c86d4a11e -r 80413ef3699a sqlpython/mysqlpy.py --- a/sqlpython/mysqlpy.py Wed Oct 14 13:57:29 2009 -0400 +++ b/sqlpython/mysqlpy.py Thu Oct 15 14:30:32 2009 -0400 @@ -185,6 +185,7 @@ def run(): my=mysqlpy() print my.__doc__ + # Arguments to sqlpython: (optional) try: if sys.argv[1][0] != '@': connectstring = sys.argv.pop(1) @@ -205,11 +206,14 @@ if __name__ == '__main__': parser = optparse.OptionParser() parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') - (callopts, callargs) = parser.parse_args() - if callopts.unittests: - mysqlpy.testfiles = callargs - sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() - unittest.main() + try: + (callopts, callargs) = parser.parse_args() + if callopts.unittests: + mysqlpy.testfiles = callargs + sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() + unittest.main() + except optparse.BadOptionError: + pass else: #import cProfile, pstats #cProfile.run('run()', 'stats.txt')