Browse Source

Tests passing

Ask Solem 13 years ago
parent
commit
79cb8911a8

+ 1 - 1
celery/tests/test_app/test_beat.py

@@ -165,7 +165,7 @@ class test_Scheduler(Case):
             def apply_async(cls, *args, **kwargs):
                 through_task[0] = True
 
-        assert MockTask.name in MockTask.app.tasks
+        assert MockTask.name in MockTask._get_app().tasks
 
         scheduler = mScheduler()
         scheduler.apply_async(scheduler.Entry(task=MockTask.name))

+ 8 - 6
celery/tests/test_task/__init__.py

@@ -333,7 +333,7 @@ class TestCeleryTasks(Case):
 
     def test_task_class_repr(self):
         task = self.createTaskCls("T1", "c.unittest.t.repr")
-        self.assertIn("class Task of", repr(task.app.Task))
+        self.assertIn("class Task of", repr(task._get_app().Task))
 
     def test_after_return(self):
         task = self.createTaskCls("T1", "c.unittest.t.after_return")()
@@ -343,9 +343,10 @@ class TestCeleryTasks(Case):
 
     def test_send_task_sent_event(self):
         T1 = self.createTaskCls("T1", "c.unittest.t.t1")
-        conn = T1.app.broker_connection()
+        app = T1._get_app()
+        conn = app.broker_connection()
         chan = conn.channel()
-        T1.app.conf.CELERY_SEND_TASK_SENT_EVENT = True
+        app.conf.CELERY_SEND_TASK_SENT_EVENT = True
         dispatcher = [None]
 
         class Pub(object):
@@ -357,7 +358,7 @@ class TestCeleryTasks(Case):
         try:
             T1.apply_async(publisher=Pub())
         finally:
-            T1.app.conf.CELERY_SEND_TASK_SENT_EVENT = False
+            app.conf.CELERY_SEND_TASK_SENT_EVENT = False
             chan.close()
             conn.close()
 
@@ -470,12 +471,13 @@ class TestTaskApply(Case):
             RaisingTask.apply(throw=True)
 
     def test_apply_with_CELERY_EAGER_PROPAGATES_EXCEPTIONS(self):
-        RaisingTask.app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
+        app = RaisingTask._get_app()
+        app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
         try:
             with self.assertRaises(KeyError):
                 RaisingTask.apply()
         finally:
-            RaisingTask.app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = False
+            app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = False
 
     def test_apply(self):
         IncrementCounterTask.count = 0

+ 3 - 9
celery/tests/test_task/test_task_http.py

@@ -14,7 +14,7 @@ except ImportError:  # py3k
 from anyjson import serialize
 
 from celery.task import http
-from celery.tests.utils import Case
+from celery.tests.utils import Case, eager_tasks
 from celery.utils.compat import StringIO
 from celery.utils.encoding import from_utf8
 
@@ -155,19 +155,13 @@ class TestHttpDispatch(Case):
 class TestURL(Case):
 
     def test_URL_get_async(self):
-        http.HttpDispatchTask.app.conf.CELERY_ALWAYS_EAGER = True
-        try:
+        with eager_tasks():
             with mock_urlopen(success_response(100)):
                 d = http.URL("http://example.com/mul").get_async(x=10, y=10)
                 self.assertEqual(d.get(), 100)
-        finally:
-            http.HttpDispatchTask.app.conf.CELERY_ALWAYS_EAGER = False
 
     def test_URL_post_async(self):
-        http.HttpDispatchTask.app.conf.CELERY_ALWAYS_EAGER = True
-        try:
+        with eager_tasks():
             with mock_urlopen(success_response(100)):
                 d = http.URL("http://example.com/mul").post_async(x=10, y=10)
                 self.assertEqual(d.get(), 100)
-        finally:
-            http.HttpDispatchTask.app.conf.CELERY_ALWAYS_EAGER = False