Python 芹菜任务在Django测试中未引发异常
我的Django测试中包含了几个芹菜任务。不幸的是,通过.delay()调用任务时不会引发异常。我将要成为现实 任务。pyPython 芹菜任务在Django测试中未引发异常,python,django,testing,celery,celery-task,Python,Django,Testing,Celery,Celery Task,我的Django测试中包含了几个芹菜任务。不幸的是,通过.delay()调用任务时不会引发异常。我将要成为现实 任务。py import celeryapp as app @app.task() def exception_task(): print 'CELERY_ALWAYS_EAGER:', app.conf['CELERY_ALWAYS_EAGER'] raise Exception('foo') def test_exception_in_task(self):
import celeryapp as app
@app.task()
def exception_task():
print 'CELERY_ALWAYS_EAGER:', app.conf['CELERY_ALWAYS_EAGER']
raise Exception('foo')
def test_exception_in_task(self):
from tasks import exception_task
exception_task.delay()
测试.py
import celeryapp as app
@app.task()
def exception_task():
print 'CELERY_ALWAYS_EAGER:', app.conf['CELERY_ALWAYS_EAGER']
raise Exception('foo')
def test_exception_in_task(self):
from tasks import exception_task
exception_task.delay()
输出
CELERY_ALWAYS_EAGER: True
.
----------------------------------------------------------------------
Ran 1 test in 0.686s
移除时。延迟测试退出,出现异常错误:
ERROR: test_exception_in_task
Exception: foo
版本
celery==3.1.4
Django==1.6.4
似乎我还必须设置为True。在芹菜4.0下,我必须使用