comparison example/example.py @ 254:07dff0ba981e

multiple test files
author Catherine Devlin <catherine.devlin@gmail.com>
date Wed, 01 Apr 2009 18:05:51 -0400
parents 7d215852f9a6
children d62bb3dd58a0
comparison
equal deleted inserted replaced
253:24289178b367 254:07dff0ba981e
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 transcriptFileName = 'exampleSession.txt' 35 transcriptExtension = 'test'
36 36
37 parser = optparse.OptionParser() 37 parser = optparse.OptionParser()
38 parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') 38 parser.add_option('-a', '--alltests', dest='test', action="store_true",
39 help='Run all transcript tests')
40 parser.add_option('-t', '--testfile', dest='testfile', metavar='FILE',
41 help='Run a single transcript from file FILE')
39 (callopts, callargs) = parser.parse_args() 42 (callopts, callargs) = parser.parse_args()
40 if callopts.unittests: 43 if callopts.testfile or callopts.test:
44 CmdLineApp.testfile = callopts.testfile
41 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() 45 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
42 unittest.main() 46 unittest.main()
43 else: 47 else:
44 app = CmdLineApp() 48 app = CmdLineApp()
45 app.cmdloop() 49 app.cmdloop()