Mercurial > python-cmd2
comparison example/example.py @ 259:5147fa4166b0
multiple transcript tests working - sinister BASH trick defeated
author | Catherine Devlin <catherine.devlin@gmail.com> |
---|---|
date | Thu, 02 Apr 2009 18:07:04 -0400 |
parents | 7a98d7f2da30 |
children | 1cd23003e8d5 |
comparison
equal
deleted
inserted
replaced
258:7a98d7f2da30 | 259:5147fa4166b0 |
---|---|
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 import logging | |
36 logging.basicConfig(level=logging.DEBUG, | |
37 filename='exlog.txt', | |
38 filemode='w') | |
39 parser = optparse.OptionParser() | 35 parser = optparse.OptionParser() |
40 parser.add_option('-t', '--test', dest='test', metavar='FILE', | 36 parser.add_option('-t', '--test', dest='test', action="store_true", |
41 help='''Test against transcript(s) in FILE (wildcards OK)''') | 37 help='Test against transcript(s) in FILE (wildcards OK)') |
42 (callopts, callargs) = parser.parse_args() | 38 (callopts, callargs) = parser.parse_args() |
43 logging.error(callopts) | |
44 if callopts.test: | 39 if callopts.test: |
45 CmdLineApp.testfile = callopts.test | 40 CmdLineApp.testfiles = callargs |
46 logging.error(CmdLineApp.testfile) | |
47 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() | 41 sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() |
48 unittest.main() | 42 unittest.main() |
49 else: | 43 else: |
50 CmdLineApp().cmdloop() | 44 CmdLineApp().cmdloop() |