'BlockingChannel.basic_publish msg delivered despite pending unroutable message'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestBasicPublishDeliveredWhenPendingUnroutable_q' + uuid.uuid1().hex)
    exg_name = ('TestBasicPublishDeliveredWhenPendingUnroutable_exg_' + uuid.uuid1().hex)
    routing_key = 'TestBasicPublishDeliveredWhenPendingUnroutable'
    ch.exchange_declare(exg_name, exchange_type='direct')
    self.addCleanup(connection.channel().exchange_delete, exg_name)
    ch.queue_declare(q_name, auto_delete=True)
    self.addCleanup(self._connect().channel().queue_delete, q_name)
    ch.queue_bind(q_name, exchange=exg_name, routing_key=routing_key)
    res = ch.basic_publish(exg_name, routing_key='', body='unroutable-message', mandatory=True)
    self.assertEqual(res, True)
    connection.channel().close()
    res = ch.basic_publish(exg_name, routing_key=routing_key, body='routable-message', mandatory=True)
    self.assertEqual(res, True)
    self._assert_exact_message_count_with_retries(channel=ch, queue=q_name, expected_count=1)
    msg = ch.basic_get(q_name)
    self.assertIsInstance(msg, tuple)
    (rx_method, rx_properties, rx_body) = msg
    self.assertIsInstance(rx_method, pika.spec.Basic.GetOk)
    self.assertEqual(rx_method.delivery_tag, 1)
    self.assertFalse(rx_method.redelivered)
    self.assertEqual(rx_method.exchange, exg_name)
    self.assertEqual(rx_method.routing_key, routing_key)
    self.assertIsInstance(rx_properties, pika.BasicProperties)
    self.assertEqual(rx_body, as_bytes('routable-message'))
    self.assertFalse(ch._pending_events)
    ch.basic_ack(delivery_tag=rx_method.delivery_tag, multiple=False)
    self._assert_exact_message_count_with_retries(channel=ch, queue=q_name, expected_count=0)
