'BlockingChannel unacked message restored to q on channel close'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestNoAckMessageNotRestoredToQueueOnChannelClose_q' + uuid.uuid1().hex)
    body1 = ('a' * 1024)
    body2 = ('b' * 2048)
    ch.queue_declare(q_name, auto_delete=False)
    self.addCleanup(self._connect().channel().queue_delete, q_name)
    ch.publish(exchange='', routing_key=q_name, body=body1)
    ch.publish(exchange='', routing_key=q_name, body=body2)
    num_messages = 0
    for (rx_method, _, _) in ch.consume(q_name, no_ack=True, exclusive=False):
        num_messages += 1
        self.assertEqual(rx_method.delivery_tag, num_messages)
        if (num_messages == 2):
            break
    else:
        self.fail(('expected    2    messages,    but    consumed    %i' % (num_messages,)))
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 0)
    ch.close()
    ch = connection.channel()
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 0)
