changeset 323:b97f1b8cdecd

added usage notes for transcript testing
author Catherine Devlin <catherine.devlin@gmail.com>
date Fri, 03 Apr 2009 08:00:45 -0400
parents d791333902f7
children 9cbea1d8872e
files sqlpython/exampleSession.txt sqlpython/mysqlpy.py
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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,
--- 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: