Permalink
Browse files

Issue-766 Add name attribute to tasks without one.

New-style Task subclass objects which do not define a name attribute end
up with the default obj.name = 'undefined' from Task.  When the tasks
are extracted from a loaded fabfile, obj.name should be set to the name
of the instance variable, since obj.name is used internally by fabric in
some circumstances, e.g. when `execute()` is called.  This commit sets
`obj.name = name` for task objects without a name, or with an undefined
name.
  • Loading branch information...
1 parent b602fe6 commit ae42d4d37f5068aae68e1ab4a48be8ba43c494f3 Todd DeLuca committed with bitprophet Nov 1, 2012
Showing with 2 additions and 0 deletions.
  1. +1 −0 fabric/main.py
  2. +1 −0 tests/test_main.py
View
@@ -214,6 +214,7 @@ def extract_tasks(imported_vars):
if obj.name and obj.name != 'undefined':
new_style_tasks[obj.name] = obj
else:
+ obj.name = name
new_style_tasks[name] = obj
# Handle aliasing
if obj.aliases is not None:
View
@@ -455,6 +455,7 @@ def test_class_based_tasks_are_found_with_variable_name(self):
docs, funcs = load_fabfile(module)
eq_(len(funcs), 1)
ok_('foo' in funcs)
+ eq_(funcs['foo'].name, 'foo')
def test_recursion_steps_into_nontask_modules(self):
"""

0 comments on commit ae42d4d

Please sign in to comment.