changeset 166:7e7fd8e12015

capturing output to temp_test_output.txt
author catherine@Elli.myhome.westell.com
date Wed, 22 Oct 2008 17:17:50 -0400
parents 6b47784322a5
children d73915d6d852
files sqlpython/sqlpyPlus.py sqlpython/test_sqlpyPlus.py
diffstat 2 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Wed Oct 22 16:33:37 2008 -0400
+++ b/sqlpython/sqlpyPlus.py	Wed Oct 22 17:17:50 2008 -0400
@@ -986,11 +986,11 @@
         object_type, owner, object_name = self.resolve(arg)
         if object_type == 'TABLE':
             self.do_select(queries['refs'],bindVarsIn={'object_name':object_name, 'owner':owner})
-    
+   
 def _test():
     import doctest
     doctest.testmod()
-
+    
 if __name__ == "__main__":
     "Silent return implies that all unit tests succeeded.  Use -v to see details."
     _test()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sqlpython/test_sqlpyPlus.py	Wed Oct 22 17:17:50 2008 -0400
@@ -0,0 +1,22 @@
+import unittest, sys, tempfile
+from sqlpyPlus import *
+class TestSqlPyPlus(unittest.TestCase):
+    def setUp(self):
+        self.oldStdOut = sys.stdout
+        self.testsession = sqlpyPlus()
+        self.testsession.onecmd('connect testdata/testdata@orcl')
+    def assertOutput(self, commandtext, expected):
+        self.testsession.onecmd(commandtext + ' > temp_test_output.txt')
+        resultfile = open('temp_test_output.txt')
+        result = resultfile.read()
+        resultfile.close()
+        self.assertEqual(expected, result)
+    def testselect(self):
+        self.assertOutput('select * from species;', '''
+        blah
+        ''')
+        self.assertOutput
+    def tearDown(self):
+        sys.stdout = self.oldStdOut
+
+unittest.main()
\ No newline at end of file