@inlineCallbacks
    def test_purge(self):
        channel = self.channel
        #setup, declare a queue and add some messages to it:
        yield channel.exchange_declare(exchange="test-exchange", type="direct")
        yield channel.queue_declare(queue="test-queue", exclusive=True)
        yield channel.queue_bind(queue="test-queue", exchange="test-exchange", routing_key="key")
        channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("one"))
        channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("two"))
        channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("three"))

        #check that the queue now reports 3 messages:
        reply = yield channel.queue_declare(queue="test-queue")
        self.assertEqual(3, reply.message_count)

        #now do the purge, then test that three messages are purged and the count drops to 0
        reply = yield channel.queue_purge(queue="test-queue");
        self.assertEqual(3, reply.message_count)        
        reply = yield channel.queue_declare(queue="test-queue")
        self.assertEqual(0, reply.message_count)

        #send a further message and consume it, ensuring that the other messages are really gone
        channel.basic_publish(exchange="test-exchange", routing_key="key", content=Content("four"))
        reply = yield channel.basic_consume(queue="test-queue", no_ack=True)
        queue = yield self.client.queue(reply.consumer_tag)
        msg = yield queue.get(timeout=1)
        self.assertEqual("four", msg.content.body)

        #check error conditions (use new channels): 
        channel = yield self.client.channel(2)
        yield channel.channel_open()
        try:
            #queue specified but doesn't exist:
            yield channel.queue_purge(queue="invalid-queue")
            self.fail("Expected failure when purging non-existent queue")
        except Closed, e:
            self.assertChannelException(404, e.args[0])

        channel = yield self.client.channel(3)
        yield channel.channel_open()
        try:
            #queue not specified and none previously declared for channel:
            yield channel.queue_purge()
            self.fail("Expected failure when purging unspecified queue")
        except Closed, e:
            self.assertConnectionException(530, e.args[0])

        #cleanup    
        other = yield self.connect()
        channel = yield other.channel(1)
        yield channel.channel_open()
        yield channel.exchange_delete(exchange="test-exchange")
Start the timer, return the previous duration.
dataset/ETHPy150Open williamsjj/txamqp/src/txamqp/test/test_queue.py/QueueTests.test_purge--crossover with--dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlsys_timer.py/Timer.restart