Skip to content

Commit

Permalink
Tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Apr 3, 2012
1 parent bbfd2f9 commit 5998dc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions celery/task/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -56,9 +57,12 @@ def __init__(self, task=None, args=None, kwargs=None, options=None,
# 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),
Expand Down Expand Up @@ -189,7 +193,7 @@ def total(self):
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
Expand Down
1 change: 1 addition & 0 deletions celery/tests/test_task/test_task_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_is_JSON_serializable(self):
{"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))))
Expand Down

0 comments on commit 5998dc9

Please sign in to comment.