comparison cmd2.py @ 322:7cd74e42b7f9

transcript test running again
author catherine@dellzilla
date Thu, 11 Feb 2010 14:41:07 -0500
parents b9f19255d4b7
children fc1e5a141920
comparison
equal deleted inserted replaced
321:92770d2c8438 322:7cd74e42b7f9
1442 command = [line[len(self.cmdapp.prompt):]] 1442 command = [line[len(self.cmdapp.prompt):]]
1443 line = transcript.next() 1443 line = transcript.next()
1444 while line.startswith(self.cmdapp.continuation_prompt): 1444 while line.startswith(self.cmdapp.continuation_prompt):
1445 command.append(line[len(self.cmdapp.continuation_prompt):]) 1445 command.append(line[len(self.cmdapp.continuation_prompt):])
1446 line = transcript.next() 1446 line = transcript.next()
1447 command = ''.join(command).strip() 1447 command = ''.join(command)
1448 self.cmdapp.onecmd(command) 1448 self.cmdapp.onecmd(command)
1449 result = self.outputTrap.read().strip() 1449 result = self.outputTrap.read()
1450 if line.startswith(self.cmdapp.prompt): 1450 if line.startswith(self.cmdapp.prompt):
1451 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected: (nothing)\nGot:\n%s\n'%\ 1451 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected: (nothing)\nGot:\n%s\n'%\
1452 (fname, lineNum, command, result) 1452 (fname, lineNum, command, result)
1453 self.assert_(not(result.strip()), message) 1453 self.assert_(not(result.strip()), message)
1454 continue 1454 continue
1455 expected = [] 1455 expected = []
1456 while not line.startswith(self.cmdapp.prompt): 1456 while not line.startswith(self.cmdapp.prompt):
1457 expected.append(line) 1457 expected.append(line)
1458 line = transcript.next() 1458 line = transcript.next()
1459 expected = ''.join(expected).strip() 1459 expected = ''.join(expected)
1460 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n'%\ 1460 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n'%\
1461 (fname, lineNum, command, expected, result) 1461 (fname, lineNum, command, expected, result)
1462 expected = self.expectationParser.transformString(expected) 1462 expected = self.expectationParser.transformString(expected)
1463 expected = self.endStrippingRegex.sub('\s*\n', expected) 1463 expected = self.endStrippingRegex.sub('\s*\n', expected)
1464 self.assert_(re.match(expected, result, re.MULTILINE | re.DOTALL), message) 1464 self.assert_(re.match(expected, result, re.MULTILINE | re.DOTALL), message)