Browse Source

Tests passing

Ask Solem 13 years ago
parent
commit
5998dc93f1
2 changed files with 7 additions and 2 deletions
  1. 6 2
      celery/task/sets.py
  2. 1 0
      celery/tests/test_task/test_task_sets.py

+ 6 - 2
celery/task/sets.py

@@ -45,6 +45,7 @@ class subtask(AttributeDict):
         {"task": "tasks.add", args=(2, 2), kwargs={}, options={}}
 
     """
+    _type = None
 
     def __init__(self, task=None, args=None, kwargs=None, options=None,
                 type=None, **ex):
@@ -56,9 +57,12 @@ class subtask(AttributeDict):
         # Also supports using task class/instance instead of string name.
         try:
             task_name = task.name
-            self._type = task
         except AttributeError:
             task_name = task
+        else:
+            # need to use super here, since AttributeDict
+            # will add it to dict(self)
+            object.__setattr__(self, "_type", task)
 
         init(task=task_name, args=tuple(args or ()),
                              kwargs=dict(kwargs or {}, **ex),
@@ -189,7 +193,7 @@ class group(UserList):
         return len(self)
 
     def _get_app(self):
-        return self._app or self.data[0].type.app
+        return self._app or self.data[0].type._get_app()
 
     def _set_app(self, app):
         self._app = app

+ 1 - 0
celery/tests/test_task/test_task_sets.py

@@ -83,6 +83,7 @@ class test_subtask(Case):
                 {"routing_key": "CPU-bound"})
         s.args = list(s.args)                   # tuples are not preserved
                                                 # but this doesn't matter.
+        print(dict(s))
         self.assertEqual(s,
                          subtask(anyjson.deserialize(
                              anyjson.serialize(s))))