def test_get_many_raises_inner_block(self): with patch('kombu.connection.Connection.drain_events') as drain: drain.side_effect = KeyError('foo') b = AMQPBackend(self.app) with self.assertRaises(KeyError): next(b.get_many(['id1']))