从Django单元获取芹菜任务列表

2024-04-24 12:18:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在运行单元测试时检索在tasks.py中注册的所有任务的列表。在

在我正常的环境中,我使用电流_应用程序任务要检索任务列表,但不幸的是,在运行测试时,该列表只返回:

<@task: celery.backend_cleanup of default:0x35d27b0>
<@task: celery.chain of default:0x35d27b0>
<@task: celery.chord of default:0x35d27b0>
<@task: celery.chord_unlock of default:0x35d27b0>
<@task: celery.chunks of default:0x35d27b0>
<@task: celery.group of default:0x35d27b0>
<@task: celery.map of default:0x35d27b0>
<@task: celery.starmap of default:0x35d27b0>

Tags: ofpybackend应用程序defaultchain列表task
1条回答
网友
1楼 · 发布于 2024-04-24 12:18:21

Celery任务正在导入时添加和评估,考虑到我的模型是调用任务的模型,它们只是还没有导入到当前的应用程序中。在

一个简单的解决方案就是在单元测试文件夹上做一个import tasks。在

新手错误。在

相关问题 更多 >