changeset 168:35ed0e0c63d9

oops, caught html rendering error
author catherine@Elli.myhome.westell.com
date Wed, 22 Oct 2008 22:55:38 -0400
parents d73915d6d852
children 1736fd6ae3e8
files sqlpython/test_sqlpyPlus.py
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/test_sqlpyPlus.py	Wed Oct 22 17:47:52 2008 -0400
+++ b/sqlpython/test_sqlpyPlus.py	Wed Oct 22 22:55:38 2008 -0400
@@ -1,30 +1,28 @@
-import unittest, sys, tempfile
+import unittest, sys, tempfile, re
 from sqlpyPlus import *
 class TestSqlPyPlus(unittest.TestCase):
+    transcriptReader = re.compile('testdata@orcl> (.*?)\n\n(.*?)(?=testdata@orcl>)', re.DOTALL)
     def setUp(self):
+        transcriptFile = open('test_sqlpyPlus.txt')
+        self.transcript = transcriptFile.read()
+        transcriptFile.close()
+        self.directives = self.transcriptReader.finditer(self.transcript)        
         self.testsession = sqlpyPlus()
         self.testsession.onecmd('connect testdata/testdata@orcl')
     def assertOutput(self, commandtext, expected):
-        oldStdOut = sys.stdout
-        oldStdErr = sys.stderr
-        tempoutput = tempfile.TemporaryFile()
-        temperr = tempfile.TemporaryFile()
-        sys.stdout = tempoutput
-        sys.stderr = temperr
         self.testsession.onecmd(commandtext)
-        tempoutput.seek(0)
-        result = tempoutput.read() + temperr.read()
+        falseStdOut.seek(0)
+        result = falseStdOut.read()
         self.assertEqual(expected, result)
-        sys.stdout = oldStdOut
-        sys.stderr = oldStdErr
-    def testselect(self):
-        self.assertOutput('select * from species;', '''
-        blah
-        ''')
-        self.assertOutput
+    def testall(self):
+        for directive in self.directives:
+            (command, result) = directive.groups()
+            self.assertOutput(command, result)
     def tearDown(self):
         pass
 
+falseStdOut = tempfile.TemporaryFile()
 trueStdOut = sys.stdout
+sys.stdout = falseStdOut
 unittest.main()
 sys.stdout = trueStdOut
\ No newline at end of file