'BlockingChannel unacked message restored to q on channel close'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestUnackedMessageAutoRestoredToQueueOnChannelClose_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)
    rx_messages = []
    ch.basic_consume((lambda *args: rx_messages.append(args)), q_name, no_ack=False, exclusive=False, arguments=None)
    while (len(rx_messages) != 2):
        connection.process_data_events(time_limit=None)
    self.assertEqual(rx_messages[0][1].delivery_tag, 1)
    self.assertEqual(rx_messages[1][1].delivery_tag, 2)
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 0)
    ch.close()
    ch = connection.channel()
    self._assert_exact_message_count_with_retries(channel=ch, queue=q_name, expected_count=2)
