本文整理匯總了Python中st2common.runners.paramiko_ssh.ParamikoSSHClient._consume_stdout方法的典型用法代碼示例。如果您正苦於以下問題:Python ParamikoSSHClient._consume_stdout方法的具體用法?Python ParamikoSSHClient._consume_stdout怎麽用?Python ParamikoSSHClient._consume_stdout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類st2common.runners.paramiko_ssh.ParamikoSSHClient
的用法示例。
在下文中一共展示了ParamikoSSHClient._consume_stdout方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_consume_stdout
# 需要導入模塊: from st2common.runners.paramiko_ssh import ParamikoSSHClient [as 別名]
# 或者: from st2common.runners.paramiko_ssh.ParamikoSSHClient import _consume_stdout [as 別名]
def test_consume_stdout(self):
# Test utf-8 decoding of ``stdout`` still works fine when reading CHUNK_SIZE splits a
# multi-byte utf-8 character in the middle. We should wait to collect all bytes
# and finally decode.
conn_params = {'hostname': 'dummy.host.org',
'username': 'ubuntu'}
mock = ParamikoSSHClient(**conn_params)
mock.CHUNK_SIZE = 1
chan = Mock()
chan.recv_ready.side_effect = [True, True, True, True, False]
chan.recv.side_effect = ['\xF0', '\x90', '\x8D', '\x88']
try:
'\xF0'.decode('utf-8')
self.fail('Test fixture is not right.')
except UnicodeDecodeError:
pass
stdout = mock._consume_stdout(chan)
self.assertEqual(u'\U00010348', stdout.getvalue())