comparison cmd2.py @ 179:321e0cc35661

oh no... must accept prompt changes
author catherine@Elli.myhome.westell.com
date Wed, 24 Dec 2008 09:46:27 -0500
parents f2b1643b5173
children 951c124b0404
comparison
equal deleted inserted replaced
178:4e1ed90962bc 179:321e0cc35661
446 446
447 """ 447 """
448 if not line: 448 if not line:
449 return self.emptyline() 449 return self.emptyline()
450 if not pyparsing.Or(self.commentGrammars).setParseAction(lambda x: '').transformString(line): 450 if not pyparsing.Or(self.commentGrammars).setParseAction(lambda x: '').transformString(line):
451 return 0 451 return 0 # command was empty except for comments
452 try: 452 try:
453 statement = self.parsed(line) 453 statement = self.parsed(line)
454 while statement.parsed.multilineCommand and (statement.parsed.terminator == ''): 454 while statement.parsed.multilineCommand and (statement.parsed.terminator == ''):
455 statement = self.parsed('%s\n%s' % (statement.parsed.raw, 455 statement = self.parsed('%s\n%s' % (statement.parsed.raw,
456 self.pseudo_raw_input(self.continuationPrompt))) 456 self.pseudo_raw_input(self.continuationPrompt)))
906 response = [] 906 response = []
907 elif line.startswith(continuationPrompt): 907 elif line.startswith(continuationPrompt):
908 command.append(line[len(continuationPrompt)+1:]) 908 command.append(line[len(continuationPrompt)+1:])
909 else: 909 else:
910 response.append(line) 910 response.append(line)
911 def assertEqualWithWildcards(self, got, expected, message):
912 got = got.strip()
913 expected = expected.strip()
914 try:
915 self.assertEqual(got, expected, message)
916 except AssertionError:
917 print 'ooh, this is bad'
918 raise
911 def testall(self): 919 def testall(self):
912 if self.CmdApp: 920 if self.CmdApp:
913 self.divideTranscript() 921 self.divideTranscript()
914 for (lineNum, command, expected) in self.dialogue: 922 for (lineNum, command, expected) in self.dialogue:
915 self.cmdapp.onecmd(command) 923 self.cmdapp.onecmd(command)
916 result = self.outputTrap.read() 924 result = self.outputTrap.read()
917 self.assertEqual(result.strip(), expected.strip(), 925 self.assertEqualWithWildcards(result, expected,
918 '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n' % 926 '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n' %
919 (self.transcriptFileName, lineNum, command, expected, result)) 927 (self.transcriptFileName, lineNum, command, expected, result))
920 def tearDown(self): 928 def tearDown(self):
921 if self.CmdApp: 929 if self.CmdApp:
922 self.outputTrap.tearDown() 930 self.outputTrap.tearDown()