|
3 | 3 | from django.conf import settings
|
4 | 4 | from django.test.simple import DjangoTestSuiteRunner
|
5 | 5 |
|
6 |
| -from djcelery.app import app |
7 |
| -from djcelery.backends.database import DatabaseBackend |
| 6 | +from celery import current_app |
8 | 7 | from celery.task import Task
|
| 8 | +from djcelery.backends.database import DatabaseBackend |
9 | 9 |
|
10 | 10 |
|
11 | 11 | USAGE = """\
|
|
15 | 15 |
|
16 | 16 | def _set_eager():
|
17 | 17 | settings.CELERY_ALWAYS_EAGER = True
|
18 |
| - app.conf.CELERY_ALWAYS_EAGER = True |
| 18 | + current_app.conf.CELERY_ALWAYS_EAGER = True |
19 | 19 | 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 |
21 | 21 |
|
22 | 22 |
|
23 | 23 | class CeleryTestSuiteRunner(DjangoTestSuiteRunner):
|
@@ -54,7 +54,8 @@ class CeleryTestSuiteRunnerStoringResult(DjangoTestSuiteRunner):
|
54 | 54 | def setup_test_environment(self, **kwargs):
|
55 | 55 | # Monkey-patch Task.on_success() method
|
56 | 56 | 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') |
58 | 59 | Task.on_success = classmethod(on_success_patched)
|
59 | 60 |
|
60 | 61 | super(CeleryTestSuiteRunnerStoringResult, self).setup_test_environment(
|
|
0 commit comments