You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SM_BG_TASKS_TASK_ALWAYS_EAGER ineffective for tests that don't use the client fixture #71
SM_BG_TASKS_TASK_ALWAYS_EAGER=true is documented as the way to run Celery tasks inline in tests. In practice, the eager-mode patch only takes effect after host_conftest._patch_celery_eager() runs AND after the FastAPI lifespan fires (the client fixture). Tests that only use the db fixture (no client) never trigger the lifespan, never resolve the global Celery app, and task.delay() tries to hit the real broker.
This eagerly bootstraps the Celery app at conftest import time (before any test fixtures resolve), so task.delay() finds it and respects the eager flag.
Suggested fix
The patch in host_conftest._patch_celery_eager should also call build_celery() once at module load to register the global Celery app. That way module conftests don't need to repeat the bootstrap.
Alternatively, change simple_module_background_tasks so BackgroundTasksSettings.task_always_eager is honoured by build_celery directly (read at instantiation), and the framework calls build_celery() from host_conftest regardless of lifespan firing.
Impact
Every module testing a Celery task without using the FastAPI test client carries this conftest hack.
Closing — addressed by commit ade3e24 (PR #98). BackgroundTasksSettings now exposes task_always_eager (read from SM_BG_TASKS_TASK_ALWAYS_EAGER) and task_eager_propagates, and build_celery() honours both at instantiation. simple_module_test.plugin pre-builds the eager Celery app at conftest import time so tests using only the db fixture (no client) still get inline task execution.
Activity
fix: address framework papercuts (#66, #68, #71, #73, #75, #76, #81, #90
antosubash commentedon May 1, 2026
Closing — addressed by commit ade3e24 (PR #98).
BackgroundTasksSettingsnow exposestask_always_eager(read fromSM_BG_TASKS_TASK_ALWAYS_EAGER) andtask_eager_propagates, andbuild_celery()honours both at instantiation.simple_module_test.pluginpre-builds the eager Celery app at conftest import time so tests using only thedbfixture (noclient) still get inline task execution.Generated by Claude Code