Testing code which uses Celery

Some of the Celery docs - for example, here - will tell you to use CELERY_ALWAYS_EAGER=True when testing so the task runs immediately. This is not the right variable.

Cartoon celery stalk
Celery picture by Nanda Pratama

Despite the image, I mean the task scheduling software, not the vegetable.

Having just spent an annoying amount of time on this I'm writing it down for posterity, in the hope it'll save someone else from wasting time too.

Some of the Celery docs - for example, here - will tell you to use CELERY_ALWAYS_EAGER=True when testing so the task runs immediately.

This is not the right variable.

The one you want is CELERY_TASK_ALWAYS_EAGER=True, as per this link from other Celery docs. (Their documentation is ... not as good as the Django docs.)

Subscribe to Paul Walker

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe