# HG changeset patch # User catherine@dellzilla # Date 1265928449 18000 # Node ID 237a89d5a4a91ea133daac349ac817058db8316b # Parent 4172feeddf76c1a74d965a63114bc6eb6946955e run() working diff -r 4172feeddf76 -r 237a89d5a4a9 cmd2.py --- 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() diff -r 4172feeddf76 -r 237a89d5a4a9 example/example.py --- 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()''' diff -r 4172feeddf76 -r 237a89d5a4a9 example/exampleSession.txt --- 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