@patch('socket.socket')
    def test_connect(self, mock_socket):
        self.assertDictEqual(network.connect(False, 'port'),
                             {'comment': 'Required argument, host, is missing.',
                              'result': False})

        self.assertDictEqual(network.connect('host', False),
                             {'comment': 'Required argument, port, is missing.',
                              'result': False})

        ret = 'Unable to connect to host (0) on tcp port port'
        mock_socket.side_effect = Exception('foo')
        with patch.object(salt.utils.network, 'sanitize_host',
                          return_value='A'):
            with patch.object(socket, 'getaddrinfo',
                              return_value=[['ipv4', 'A', 6, 'B', '0.0.0.0']]):
                self.assertDictEqual(network.connect('host', 'port'),
                                     {'comment': ret, 'result': False})

        ret = 'Successfully connected to host (0) on tcp port port'
        mock_socket.side_effect = MagicMock()
        mock_socket.settimeout().return_value = None
        mock_socket.connect().return_value = None
        mock_socket.shutdown().return_value = None
        with patch.object(salt.utils.network, 'sanitize_host',
                          return_value='A'):
            with patch.object(socket,
                              'getaddrinfo',
                              return_value=[['ipv4',
                                            'A', 6, 'B', '0.0.0.0']]):
                self.assertDictEqual(network.connect('host', 'port'),
                                     {'comment': ret, 'result': True})
L{_collectWarnings}'s behavior is not altered by the presence of an
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/network_test.py/NetworkTestCase.test_connect--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/trial/test/test_warning.py/CollectWarningsTests.test_immutableObject