def test_lineReceived(self): """ lineReceived should parse the args and call runCmd """ s = ShellProtocol() called = [] def parseCmd(s): called.append(('parse', s)) return ['parsed', 'arg'] def runCmd(cmd, *args): called.append(('run', cmd, args)) s.parseCmd = parseCmd s.runCmd = runCmd s.lineReceived('how are you') self.assertEqual(len(called), 2) self.assertEqual(called[0], ('parse', 'how are you')) self.assertEqual(called[1], ('run', 'parsed', ('arg',)))
def t(self, i, expected_output): s = ShellProtocol() r = s.parseCmd(i) self.assertEqual(r, expected_output, "From parseCmd(%r)" % i)