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': '******'} 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())