2014-02-26 42 views
0

我想檢索在運行單元測試時在tasks.py中註冊的所有任務的列表。從django單元測試中獲取芹菜任務列表

在我正常的環境中我使用current_app.tasks檢索任務的列表,但運行測試,而不幸的名單只是返回:

<@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> 

回答

0

芹菜任務被添加和進口進行評估,給出的事實上,我的模型是那些正在調用任務的人,他們只是沒有被導入到current_app中。

一個簡單的解決方案就是在單元測試文件夾之上做一個import tasks

新人的錯誤。