comparison cmd2.py @ 272:d68d83f42254

fixed unit test
author catherine@cordelia
date Wed, 29 Apr 2009 22:33:58 -0400
parents 194160b7f091
children fd5197498667
comparison
equal deleted inserted replaced
270:194160b7f091 272:d68d83f42254
24 """ 24 """
25 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest 25 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest
26 import unittest, string, datetime, urllib, glob 26 import unittest, string, datetime, urllib, glob
27 from code import InteractiveConsole, InteractiveInterpreter, softspace 27 from code import InteractiveConsole, InteractiveInterpreter, softspace
28 from optparse import make_option 28 from optparse import make_option
29 __version__ = '0.5.2' 29 __version__ = '0.5.3'
30 30
31 class OptionParser(optparse.OptionParser): 31 class OptionParser(optparse.OptionParser):
32 def exit(self, status=0, msg=None): 32 def exit(self, status=0, msg=None):
33 self.values._exit = True 33 self.values._exit = True
34 if msg: 34 if msg:
317 else: 317 else:
318 cmd.Cmd.do_help(self, arg) 318 cmd.Cmd.do_help(self, arg)
319 319
320 def __init__(self, *args, **kwargs): 320 def __init__(self, *args, **kwargs):
321 cmd.Cmd.__init__(self, *args, **kwargs) 321 cmd.Cmd.__init__(self, *args, **kwargs)
322 self.initial_stdout = sys.stdout
322 self.history = History() 323 self.history = History()
323 self._init_parser() 324 self._init_parser()
324 self.pystate = {} 325 self.pystate = {}
325 self.shortcuts = sorted(self.shortcuts.items(), reverse=True) 326 self.shortcuts = sorted(self.shortcuts.items(), reverse=True)
326 self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) 327 self.keywords = self.reserved_words + [fname[3:] for fname in dir(self)
473 - args: has > inside 474 - args: has > inside
474 - multilineCommand: multiline 475 - multilineCommand: multiline
475 - terminator: ; 476 - terminator: ;
476 - terminator: ; 477 - terminator: ;
477 >>> print c.parser.parseString('multiline command /* with comment in progress;').dump() 478 >>> print c.parser.parseString('multiline command /* with comment in progress;').dump()
478 ['multiline', ' command /* with comment in progress;'] 479 ['multiline', ' command']
479 - multilineCommand: multiline 480 - multilineCommand: multiline
480 >>> print c.parser.parseString('multiline command /* with comment complete */ is done;').dump() 481 >>> print c.parser.parseString('multiline command /* with comment complete */ is done;').dump()
481 ['multiline', 'command /* with comment complete */ is done', ';', ''] 482 ['multiline', 'command /* with comment complete */ is done', ';', '']
482 - args: command /* with comment complete */ is done 483 - args: command /* with comment complete */ is done
483 - multilineCommand: multiline 484 - multilineCommand: multiline
484 - statement: ['multiline', 'command /* with comment complete */ is done', ';'] 485 - statement: ['multiline', 'command /* with comment complete */ is done', ';']