changeset 326:237a89d5a4a9

run() working
author catherine@dellzilla
date Thu, 11 Feb 2010 17:47:29 -0500
parents 4172feeddf76
children e9eea93c777c
files cmd2.py example/example.py example/exampleSession.txt
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Thu Feb 11 17:03:45 2010 -0500
+++ b/cmd2.py	Thu Feb 11 17:47:29 2010 -0500
@@ -1430,7 +1430,7 @@
             self.outputTrap = OutputTrap()
             self.cmdapp = self.CmdApp()
             self.fetchTranscripts()
-    def testall(self):
+    def runTest(self): # was testall
         if self.CmdApp:
             its = sorted(self.transcripts.items())
             for (fname, transcript) in its:
@@ -1485,9 +1485,12 @@
                       help='Test against transcript(s) in FILE (wildcards OK)')
     (callopts, callargs) = parser.parse_args()
     if callopts.test:
-        app.testfiles = callargs
+        app.__class__.testfiles = callargs
         sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
-        unittest.main()
+        testcase = TestMyAppCase()
+        runner = unittest.TextTestRunner()
+        result = runner.run(testcase)
+        result.printErrors()
     else:
         app.cmdloop()   
 
--- a/example/example.py	Thu Feb 11 17:03:45 2010 -0500
+++ b/example/example.py	Thu Feb 11 17:47:29 2010 -0500
@@ -31,8 +31,9 @@
     do_orate = do_speak   # another synonym, but this one takes multi-line input
 
 c = CmdLineApp()
-#run(c)
+run(c)
 
+'''
 class TestMyAppCase(Cmd2TestCase):
     CmdApp = CmdLineApp
 parser = optparse.OptionParser()
@@ -44,4 +45,4 @@
     sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
     unittest.main()
 else:
-    CmdLineApp().cmdloop()
+    CmdLineApp().cmdloop()'''
--- a/example/exampleSession.txt	Thu Feb 11 17:03:45 2010 -0500
+++ b/example/exampleSession.txt	Thu Feb 11 17:47:29 2010 -0500
@@ -45,7 +45,7 @@
 maxrepeats - was: 3
 now: 5
 (Cmd) say -ps --repeat=5 goodnight, Gracie
-OODNIGHT, GRACIEGAY
+OODNIGHT, GRACIEGAYo
 OODNIGHT, GRACIEGAY
 OODNIGHT, GRACIEGAY
 OODNIGHT, GRACIEGAY