def runTest(self): """ try echoing some text and see if it comes back out """ p.send_all(self.shell, "echo hello\n") time.sleep(0.1) self.assertEqual(p.recv_some(self.shell), "hello\n") p.send_all(self.shell, "echo hello world\n") time.sleep(0.1) self.assertEqual(p.recv_some(self.shell), "hello world\n") p.send_all(self.shell, "exit\n") time.sleep(0.2) self.assertEqual("", p.recv_some(self.shell, e=False)) self.assertRaises(Exception, p_recv_some_exception, self.shell)
def p_recv_some_exception(*args, **kwargs): """Call recv_some with raise exception enabled""" kwargs['e'] = True return p.recv_some(*args, **kwargs)