comparison example/example.py @ 257:d62bb3dd58a0

multiple test files still not quite working, yet works when run through debugger, aaargh
author Catherine Devlin <catherine.devlin@gmail.com>
date Thu, 02 Apr 2009 15:55:33 -0400
parents 07dff0ba981e
children 7a98d7f2da30
comparison
equal deleted inserted replaced
256:9ec55d2b3e99 257:d62bb3dd58a0
30 do_say = do_speak # now "say" is a synonym for "speak" 30 do_say = do_speak # now "say" is a synonym for "speak"
31 do_orate = do_speak # another synonym, but this one takes multi-line input 31 do_orate = do_speak # another synonym, but this one takes multi-line input
32 32
33 class TestMyAppCase(Cmd2TestCase): 33 class TestMyAppCase(Cmd2TestCase):
34 CmdApp = CmdLineApp 34 CmdApp = CmdLineApp
35 transcriptExtension = 'test'
36 35
37 parser = optparse.OptionParser() 36 parser = optparse.OptionParser()
38 parser.add_option('-a', '--alltests', dest='test', action="store_true", 37 parser.add_option('-t', '--test', dest='test', metavar='FILE',
39 help='Run all transcript tests') 38 help='''Test against transcript(s) in FILE (wildcards OK)''')
40 parser.add_option('-t', '--testfile', dest='testfile', metavar='FILE',
41 help='Run a single transcript from file FILE')
42 (callopts, callargs) = parser.parse_args() 39 (callopts, callargs) = parser.parse_args()
43 if callopts.testfile or callopts.test: 40 if callopts.test:
44 CmdLineApp.testfile = callopts.testfile 41 CmdLineApp.testfile = callopts.test
45 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() 42 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
46 unittest.main() 43 unittest.main()
47 else: 44 else:
48 app = CmdLineApp() 45 CmdLineApp().cmdloop()
49 app.cmdloop()