2

I've been trying to build test cases for what I've been doing with my django project. In the project, there are few celery tasks that executes when signals (pre_save, post_delete..etc)

Also I've been using django-nose as my test_runner, so in order to get it to work together I did my own runner and inherited both classes

# -*- coding: utf-8 -*-
from django_nose import NoseTestSuiteRunner
from djcelery.contrib.test_runner import CeleryTestSuiteRunner

class MixedInTestRunner(NoseTestSuiteRunner, CeleryTestSuiteRunner):
    pass

I also updated my TEST_RUNNER to use above class, below is my celery.py conf which am importing in my settings.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()

what is weird at this point, when I run a test case for a specific app it executes successfully without any issue

./manage.py test --nologcapture -s messaging # this works

but when I run for all applications I get error for all tasks which has dependecy of a returned value from a celery task, even the result.successful() is always returning false

./manage.py test --nologcapture -s # this fails 
Mo J. Mughrabi
  • 6,747
  • 16
  • 85
  • 143
  • 1
    This link was suggested on the right: http://stackoverflow.com/questions/15582770/using-django-nose-and-django-celery-together-unit-testing?rq=1 That seems like a decent approach. Multiple inheritance is likely your problem. – Sean Perry Apr 10 '14 at 20:26

0 Answers0