task.retry = MagicMock(side_effect=Retry)

def test_task(self):
    with assert_raises(Retry):
        task()

@Celery.task(bind=True)
def task(self):
    raise self.retry()
How to test Retry in Celery application in Python?