'BlockingConnection to downed broker results in AMQPConnectionError'

def test(self):

    sock = socket.socket()
    self.addCleanup(sock.close)
    sock.bind(('127.0.0.1', 0))
    port = sock.getsockname()[1]
    sock.close()
    with self.assertRaises(pika.exceptions.AMQPConnectionError):
        self.connection = self._connect((PARAMS_URL_TEMPLATE % {'port': port}))
