Celery tasks not throwing exception in Django Tests
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Question
01:03 Accepted answer (Score 16)
01:18 Answer 2 (Score 3)
01:35 Thank you
--
Full question
https://stackoverflow.com/questions/2702...
Question links:
[CELERY_ALWAYS_EAGER]: http://celery.readthedocs.org/en/latest/...
Accepted answer links:
[CELERY_EAGER_PROPAGATES_EXCEPTIONS]: https://docs.celeryproject.org/en/stable...
Answer 2 links:
[CELERY_TASK_EAGER_PROPAGATES]: https://github.com/celery/celery/pull/40...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #testing #celery #celerytask
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Question
01:03 Accepted answer (Score 16)
01:18 Answer 2 (Score 3)
01:35 Thank you
--
Full question
https://stackoverflow.com/questions/2702...
Question links:
[CELERY_ALWAYS_EAGER]: http://celery.readthedocs.org/en/latest/...
Accepted answer links:
[CELERY_EAGER_PROPAGATES_EXCEPTIONS]: https://docs.celeryproject.org/en/stable...
Answer 2 links:
[CELERY_TASK_EAGER_PROPAGATES]: https://github.com/celery/celery/pull/40...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #testing #celery #celerytask
#avk47
ACCEPTED ANSWER
Score 16
Seems I additionally had to set CELERY_EAGER_PROPAGATES_EXCEPTIONS to True.
Celery >=5.3.1 it is CELERY_TASK_EAGER_PROPAGATES.
ANSWER 2
Score 5
Under celery 4.0, I had to use CELERY_TASK_EAGER_PROPAGATES
ANSWER 3
Score 0
@override_settings(task_always_eager=True, task_eager_propagates=True)
def test_my_task(self):
    pass
is what worked for me using Celery 5.
Documentation on config name changes: https://docs.celeryq.dev/en/stable/userguide/configuration.html