Skip to content

Commit 37c1c33

Browse files
committed
Fixes TestSuiteRunner. Closes #303
1 parent d44ecf1 commit 37c1c33

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

djcelery/contrib/test_runner.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from django.conf import settings
44
from django.test.simple import DjangoTestSuiteRunner
55

6-
from djcelery.app import app
7-
from djcelery.backends.database import DatabaseBackend
6+
from celery import current_app
87
from celery.task import Task
8+
from djcelery.backends.database import DatabaseBackend
99

1010

1111
USAGE = """\
@@ -15,9 +15,9 @@
1515

1616
def _set_eager():
1717
settings.CELERY_ALWAYS_EAGER = True
18-
app.conf.CELERY_ALWAYS_EAGER = True
18+
current_app.conf.CELERY_ALWAYS_EAGER = True
1919
settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True # Issue #75
20-
app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
20+
current_app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
2121

2222

2323
class CeleryTestSuiteRunner(DjangoTestSuiteRunner):
@@ -54,7 +54,8 @@ class CeleryTestSuiteRunnerStoringResult(DjangoTestSuiteRunner):
5454
def setup_test_environment(self, **kwargs):
5555
# Monkey-patch Task.on_success() method
5656
def on_success_patched(self, retval, task_id, args, kwargs):
57-
DatabaseBackend().store_result(task_id, retval, 'SUCCESS')
57+
app = current_app._get_current_object()
58+
DatabaseBackend(app=app).store_result(task_id, retval, 'SUCCESS')
5859
Task.on_success = classmethod(on_success_patched)
5960

6061
super(CeleryTestSuiteRunnerStoringResult, self).setup_test_environment(

0 commit comments

Comments
 (0)