'BlockingChannel non-pub-ack publish/consume many messages'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestNonPubackPublishAndConsumeManyMessages_q' + uuid.uuid1().hex)
    body = ('b' * 1024)
    num_messages_to_publish = 500
    ch.queue_declare(q_name, auto_delete=False)
    self.addCleanup(self._connect().channel().queue_delete, q_name)
    for _ in pika.compat.xrange(num_messages_to_publish):
        ch.publish(exchange='', routing_key=q_name, body=body)
    num_consumed = 0
    for (rx_method, rx_props, rx_body) in ch.consume(q_name, no_ack=False, exclusive=False, arguments=None):
        num_consumed += 1
        self.assertIsInstance(rx_method, pika.spec.Basic.Deliver)
        self.assertEqual(rx_method.delivery_tag, num_consumed)
        self.assertFalse(rx_method.redelivered)
        self.assertEqual(rx_method.exchange, '')
        self.assertEqual(rx_method.routing_key, q_name)
        self.assertIsInstance(rx_props, pika.BasicProperties)
        self.assertEqual(rx_body, as_bytes(body))
        ch.basic_ack(delivery_tag=rx_method.delivery_tag, multiple=False)
        if (num_consumed >= num_messages_to_publish):
            break
    self.assertFalse(ch._queue_consumer_generator.pending_events)
    ch.close()
    self.assertIsNone(ch._queue_consumer_generator)
    ch = connection.channel()
    self._assert_exact_message_count_with_retries(channel=ch, queue=q_name, expected_count=0)
