def test_fetch(self, n='test_fetch'):
    c = compat.Consumer(self.connection, queue=n, exchange=n, routing_key='rkey')
    self.assertIsNone(c.fetch())
    self.assertIsNone(c.fetch(no_ack=True))
    self.assertIn('basic_get', c.backend)
    callback_called = [False]

    def receive(payload, message):
        callback_called[0] = True
    c.backend.to_deliver.append('42')
    self.assertEqual(c.fetch().payload, '42')
    c.backend.to_deliver.append('46')
    c.register_callback(receive)
    self.assertEqual(c.fetch(enable_callbacks=True).payload, '46')
    self.assertTrue(callback_called[0])
def test_fetch(self, n='test_fetch'):
    c = compat.Consumer(self.connection, queue=n, exchange=n, routing_key='rkey')
    self.assertIsNone(c.fetch())
    self.assertIsNone(c.fetch(no_ack=True))
    self.assertIn('basic_get', c.backend)
    callback_called = [False]

    def receive(payload, message):
        callback_called[0] = True
    c.backend.to_deliver.append('42')
    self.assertEqual(c.fetch().payload, '42')
    c.backend.to_deliver.append('46')
    c.register_callback(receive)
    self.assertEqual(c.fetch(enable_callbacks=True).payload, '46')
    self.assertTrue(callback_called[0])