

def setUp(self):
    self.config = {
        'host': 'localhost',
        'port': 9090,
        'request_id': 0,
        'payload': b'test data',
        'payload2': b'another packet',
    }
    patcher = mock.patch('socket.create_connection', spec=True)
    self.MockCreateConn = patcher.start()
    self.addCleanup(patcher.stop)
    self.MockCreateConn().sendall.return_value = None
    payload_size = len(self.config['payload'])
    payload2_size = len(self.config['payload2'])
    self.MockCreateConn().recv.side_effect = [struct.pack('>i', payload_size), struct.pack(('>%ds' % payload_size), self.config['payload']), struct.pack('>i', payload2_size), struct.pack(('>%ds' % payload2_size), self.config['payload2']), b'']
    self.conn = KafkaConnection(self.config['host'], self.config['port'])
    self.MockCreateConn.reset_mock()

dataset/ETHPy150Open dpkp/kafka-python/test/test_conn_legacy.py ConnTest.setUp/original