# HG changeset patch # User Catherine Devlin # Date 1238760045 14400 # Node ID b97f1b8cdecd9a716207e25266397a76d016cc07 # Parent d791333902f7ccee2d639fa4c20e50fa9b880ed9 added usage notes for transcript testing diff -r d791333902f7 -r b97f1b8cdecd sqlpython/exampleSession.txt --- a/sqlpython/exampleSession.txt Wed Apr 01 16:17:46 2009 -0400 +++ b/sqlpython/exampleSession.txt Fri Apr 03 08:00:45 2009 -0400 @@ -1,3 +1,9 @@ +Transcript file for testing of sqlpython; run tests with +`python mysqlpy.py --test exampleSession.txt`. +The database `orcl` must be running and must include +user testschema, password testschema, with the RESOURCE +privilege (`GRANT RESOURCE TO testschema`). + SQL.No_Connection> connect testschema/testschema@orcl 0:testschema@orcl> CREATE TABLE play ( > title VARCHAR2(40) CONSTRAINT xpk_play PRIMARY KEY, diff -r d791333902f7 -r b97f1b8cdecd sqlpython/mysqlpy.py --- a/sqlpython/mysqlpy.py Wed Apr 01 16:17:46 2009 -0400 +++ b/sqlpython/mysqlpy.py Fri Apr 03 08:00:45 2009 -0400 @@ -10,6 +10,7 @@ from sqlpyPlus import * import sys, tempfile, optparse, unittest +import sqlalchemy class mysqlpy(sqlpyPlus): ''' @@ -200,16 +201,24 @@ except IndexError: pass my.cmdloop() - + class TestCase(Cmd2TestCase): CmdApp = mysqlpy - transcriptFileName = 'exampleSession.txt' + def setUp(self): + Cmd2TestCase.setUp(self) + try: + sqlalchemy.create_engine('oracle://testschema:testschema@orcl' + ).connect().connection.cursor().execute( + 'DROP TABLE play') + except: + pass 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() else: