code: def test_connect(_socket, conn, states):
      assert conn.state is ConnectionStates.DISCONNECTED
  
      for errno, state in states:
          _socket.connect_ex.side_effect = errno
          conn.connect()
          assert conn.state is state
  
imports: from __future__ import absolute_import
  from errno import EALREADY, EINPROGRESS, EISCONN, ECONNRESET
  import socket
  import mock
  import pytest
  from kafka.conn import BrokerConnection, ConnectionStates, collect_hosts
  from kafka.protocol.api import RequestHeader
  from kafka.protocol.metadata import MetadataRequest
  from kafka.protocol.produce import ProduceRequest
  import kafka.errors
label_desc: Use image node_id 4 for calling a global function with example usage: test_connect(_socket, conn, states) without return types