使用芹菜依赖和django nose在django中构建测试用例
我一直在尝试为我的django项目构建测试用例。在这个项目中,很少有芹菜任务在发出信号时执行(pre_save、post_delete..等) 另外,我一直使用django nose作为我的test_runner,所以为了让它一起工作,我做了自己的runner并继承了这两个类使用芹菜依赖和django nose在django中构建测试用例,django,celery,django-nose,Django,Celery,Django Nose,我一直在尝试为我的django项目构建测试用例。在这个项目中,很少有芹菜任务在发出信号时执行(pre_save、post_delete..等) 另外,我一直使用django nose作为我的test_runner,所以为了让它一起工作,我做了自己的runner并继承了这两个类 # -*- coding: utf-8 -*- from django_nose import NoseTestSuiteRunner from djcelery.contrib.test_runner import Ce
# -*- coding: utf-8 -*-
from django_nose import NoseTestSuiteRunner
from djcelery.contrib.test_runner import CeleryTestSuiteRunner
class MixedInTestRunner(NoseTestSuiteRunner, CeleryTestSuiteRunner):
pass
我还更新了我的TEST\u RUNNER
以使用上面的类,下面是我正在我的settings.py中导入的芹菜.py配置
from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery('proj',
broker='amqp://')
# Optional configuration, see the application user guide.
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'],
CELERY_RESULT_SERIALIZER='json',
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
)
if __name__ == '__main__':
app.start()
在这一点上有什么奇怪的,当我为一个特定的应用程序运行一个测试用例时,它成功地执行而没有任何问题
./manage.py test --nologcapture -s messaging # this works
但当我为所有应用程序运行时,所有任务都会出现错误,这些任务依赖于芹菜任务返回的值,即使结果.successful()总是返回false
./manage.py test --nologcapture -s # this fails
这一联系是在右方提出的:这似乎是一种体面的做法。多重继承可能是您的问题。