'BlockingChannel: unroutable messages is returned in puback mode'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    exg_name = ('TestUnroutableMessageReturnedInPubackMode_exg_' + uuid.uuid1().hex)
    routing_key = 'TestUnroutableMessageReturnedInPubackMode'
    ch.exchange_declare(exg_name, exchange_type='direct')
    self.addCleanup(connection.channel().exchange_delete, exg_name)
    ch.confirm_delivery()
    returned_messages = []
    ch.add_on_return_callback((lambda *args: returned_messages.append(args)))
    res = ch.basic_publish(exg_name, routing_key=routing_key, body='msg1', mandatory=True)
    self.assertEqual(res, False)
    res = ch.basic_publish(exg_name, routing_key=routing_key, body='msg2', mandatory=True)
    self.assertEqual(res, False)
    self.assertEqual(len(ch._pending_events), 2)
    self.assertIsInstance(ch._pending_events[0], blocking_connection._ReturnedMessageEvt)
    self.assertIsInstance(ch._pending_events[1], blocking_connection._ReturnedMessageEvt)
    repr(ch._pending_events[0])
    repr(ch._pending_events[1])
    connection.process_data_events()
    self.assertEqual(len(ch._pending_events), 0)
    (channel, method, properties, body) = returned_messages[0]
    self.assertIs(channel, ch)
    self.assertIsInstance(method, pika.spec.Basic.Return)
    self.assertEqual(method.reply_code, 312)
    self.assertEqual(method.exchange, exg_name)
    self.assertEqual(method.routing_key, routing_key)
    self.assertIsInstance(properties, pika.BasicProperties)
    self.assertEqual(body, as_bytes('msg1'))
    (channel, method, properties, body) = returned_messages[1]
    self.assertIs(channel, ch)
    self.assertIsInstance(method, pika.spec.Basic.Return)
    self.assertEqual(method.reply_code, 312)
    self.assertEqual(method.exchange, exg_name)
    self.assertEqual(method.routing_key, routing_key)
    self.assertIsInstance(properties, pika.BasicProperties)
    self.assertEqual(body, as_bytes('msg2'))
