I need mock execution of some remote command via ssh.exec_command() It returns tuple (stdin, stdout, stderr) as paramiko.ChanelFile object.
So, I have output of command as string (which I want, exec_command() to return) and the question how to create ChanelFile object with my output string.
Pseudo code:
def send_command(self, cmd)
self.client.connect(hostname=self.host,
username=self.user,
password=self.password,
timeout=self.timeout)
stdin, stdout, stderr = self.client.exec_command(cmd)
return stdin, stdout, stderr
if __name__ == '__main__':
stdin, stdout, stderr = report.send_command('ls -la')
resp = stdout.read().strip()
So I need create stout to be able run read() method on it.