@supportedBrokers(QPID, OPENAMQ)
    @inlineCallbacks
    def test_qos_prefetch_size(self):
        #setup: declare queue and subscribe
        channel = self.channel
        yield channel.queue_declare(queue="test-prefetch-size", exclusive=True)
        subscription = yield channel.basic_consume(queue="test-prefetch-size", no_ack=False)
        queue = yield self.client.queue(subscription.consumer_tag)

        #set prefetch to 50 bytes (each message is 9 or 10 bytes):
        channel.basic_qos(prefetch_size=50)

        #publish 10 messages:
        for i in range(1, 11):
            channel.basic_publish(routing_key="test-prefetch-size", content=Content("Message %d" % i))

        #only 5 messages should have been delivered (i.e. 45 bytes worth):
        for i in range(1, 6):
            msg = yield queue.get(timeout=1)
            self.assertEqual("Message %d" % i, msg.content.body)

        try:
            extra = yield queue.get(timeout=1)
            self.fail("Got unexpected 6th message in original queue: " + extra.content.body)
        except Empty: None

        #ack messages and check that the next set arrive ok:
        channel.basic_ack(delivery_tag=msg.delivery_tag, multiple=True)

        for i in range(6, 11):
            msg = yield queue.get(timeout=1)
            self.assertEqual("Message %d" % i, msg.content.body)

        channel.basic_ack(delivery_tag=msg.delivery_tag, multiple=True)

        try:
            extra = yield queue.get(timeout=1)
            self.fail("Got unexpected 11th message in original queue: " + extra.content.body)
        except Empty: None

        #make sure that a single oversized message still gets delivered
        large = "abcdefghijklmnopqrstuvwxyz"
        large = large + "-" + large;
        channel.basic_publish(routing_key="test-prefetch-size", content=Content(large))
        msg = yield queue.get(timeout=1)
        self.assertEqual(large, msg.content.body)
Decorate the string with the ansii escapes for the color.
dataset/ETHPy150Open tweetdeck/txAMQP/src/txamqp/test/test_basic.py/BasicTests.test_qos_prefetch_size--crossover with--dataset/ETHPy150Open google/grr/grr/tools/run_tests.py/Colorizer.Render