当前位置: 首页>>代码示例>>Python>>正文


Python Task.options方法代码示例

本文整理汇总了Python中doit.task.Task.options方法的典型用法代码示例。如果您正苦于以下问题:Python Task.options方法的具体用法?Python Task.options怎么用?Python Task.options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在doit.task.Task的用法示例。


在下文中一共展示了Task.options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_meta_arg_default_disallowed

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_meta_arg_default_disallowed(self):
     def py_callable(a, b, changed=None): pass
     task = Task('Fake', [(py_callable, ('a', 'b'))])
     task.options = {}
     task.dep_changed = ['changed']
     my_action = task.actions[0]
     pytest.raises(action.InvalidTask, my_action.execute)
开发者ID:pydoit,项目名称:doit,代码行数:9,代码来源:test_action.py

示例2: test_callable_invalid

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_callable_invalid(self):
     def get_cmd(blabla): pass
     task = Task('Fake', [action.CmdAction(get_cmd)])
     task.options = {'opt1':'3'}
     my_action = task.actions[0]
     got = my_action.execute()
     assert isinstance(got, TaskError)
开发者ID:pydoit,项目名称:doit,代码行数:9,代码来源:test_action.py

示例3: test_no_extra_args

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_no_extra_args(self):
     # no error trying to inject values
     def py_callable():
         return True
     task = Task('Fake', [py_callable], file_dep=['dependencies'])
     task.options = {}
     my_action = task.actions[0]
     my_action.execute()
开发者ID:pydoit,项目名称:doit,代码行数:10,代码来源:test_action.py

示例4: test_task_options

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_task_options(self):
     cmd = "%s %s/myecho.py" % (executable, TEST_PATH)
     cmd += " %(opt1)s - %(opt2)s"
     task = Task('Fake', [cmd])
     task.options = {'opt1':'3', 'opt2':'abc def'}
     my_action = task.actions[0]
     assert my_action.execute() is None
     got = my_action.out.strip()
     assert "3 - abc def" == got
开发者ID:pydoit,项目名称:doit,代码行数:11,代码来源:test_action.py

示例5: test_option_default_allowed

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_option_default_allowed(self):
     got = []
     def py_callable(opt2='ABC'):
         got.append(opt2)
     task = Task('Fake', [py_callable])
     task.options = {'opt2':'123'}
     my_action = task.actions[0]
     my_action.execute()
     assert ['123'] == got, repr(got)
开发者ID:pydoit,项目名称:doit,代码行数:11,代码来源:test_action.py

示例6: test_task_pos_arg

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_task_pos_arg(self):
     got = []
     def py_callable(pos):
         got.append(pos)
     task = Task('Fake', [py_callable], pos_arg='pos')
     task.options = {}
     task.pos_arg_val = ['hi', 'there']
     my_action = task.actions[0]
     my_action.execute()
     assert [['hi', 'there']] == got, repr(got)
开发者ID:pydoit,项目名称:doit,代码行数:12,代码来源:test_action.py

示例7: test_both

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_both(self, monkeypatch):
     monkeypatch.setattr(action.CmdAction, 'STRING_FORMAT', 'both')
     cmd = "%s %s/myecho.py" % (executable, TEST_PATH)
     cmd += " {dependencies} - %(opt1)s"
     task = Task('Fake', [cmd], ['data/dependency1'])
     task.options = {'opt1':'abc'}
     my_action = task.actions[0]
     assert my_action.execute() is None
     got = my_action.out.strip()
     assert "data/dependency1 - abc" == got
开发者ID:pydoit,项目名称:doit,代码行数:12,代码来源:test_action.py

示例8: test_callable_return_command_str

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_callable_return_command_str(self):
     def get_cmd(opt1, opt2):
         cmd = "%s %s/myecho.py" % (executable, TEST_PATH)
         return cmd + " %s - %s" % (opt1, opt2)
     task = Task('Fake', [action.CmdAction(get_cmd)])
     task.options = {'opt1':'3', 'opt2':'abc def'}
     my_action = task.actions[0]
     assert my_action.execute() is None
     got = my_action.out.strip()
     assert "3 - abc def" == got, repr(got)
开发者ID:pydoit,项目名称:doit,代码行数:12,代码来源:test_action.py

示例9: test_keyword_extra_args

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_keyword_extra_args(self):
     got = []
     def py_callable(arg=None, **kwargs):
         got.append(kwargs)
     my_task = Task('Fake', [(py_callable, (), {'b': 4})],
                    file_dep=['dependencies'])
     my_task.options = {'foo': 'bar'}
     my_action = my_task.actions[0]
     my_action.execute()
     # meta args do not leak into kwargs
     assert got == [{'foo': 'bar', 'b': 4}]
开发者ID:pydoit,项目名称:doit,代码行数:13,代码来源:test_action.py

示例10: test_task_pos_arg_None

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_task_pos_arg_None(self):
     # pos_arg_val is None when the task is not specified from
     # command line but executed because it is a task_dep
     cmd = "%s %s/myecho.py" % (executable, TEST_PATH)
     cmd += " %(pos)s"
     task = Task('Fake', [cmd], pos_arg='pos')
     task.options = {}
     my_action = task.actions[0]
     assert my_action.execute() is None
     got = my_action.out.strip()
     assert "" == got
开发者ID:pydoit,项目名称:doit,代码行数:13,代码来源:test_action.py

示例11: test_extra_kwarg_overwritten

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_extra_kwarg_overwritten(self):
     got = []
     def py_callable(a, b, **kwargs):
         got.append(a)
         got.append(b)
         got.append(kwargs['changed'])
     task = Task('Fake', [(py_callable, ('a', 'b'), {'changed': 'c'})])
     task.options = {}
     task.dep_changed = ['changed']
     my_action = task.actions[0]
     my_action.execute()
     assert got == ['a', 'b', 'c']
开发者ID:pydoit,项目名称:doit,代码行数:14,代码来源:test_action.py

示例12: test_extra_arg_overwritten

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_extra_arg_overwritten(self):
     got = []
     def py_callable(a, b, changed):
         got.append(a)
         got.append(b)
         got.append(changed)
     task = Task('Fake', [(py_callable, ('a', 'b', 'c'))])
     task.dep_changed = ['changed']
     task.options = {}
     my_action = task.actions[0]
     my_action.execute()
     assert got == ['a', 'b', 'c']
开发者ID:pydoit,项目名称:doit,代码行数:14,代码来源:test_action.py

示例13: test_mixed_args

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_mixed_args(self):
     got = []
     def py_callable(a, b, changed):
         got.append(a)
         got.append(b)
         got.append(changed)
     task = Task('Fake', [(py_callable, ('a', 'b'))])
     task.options = {}
     task.dep_changed = ['changed']
     my_action = task.actions[0]
     my_action.execute()
     assert got == ['a', 'b', ['changed']]
开发者ID:pydoit,项目名称:doit,代码行数:14,代码来源:test_action.py

示例14: test_kwonlyargs_minimal

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_kwonlyargs_minimal(self):
     got = []
     scope = {'got': got}
     exec(textwrap.dedent('''
         def py_callable(*args, kwonly=None):
             got.append(args)
             got.append(kwonly)
     '''), scope)
     task = Task('Fake', [(scope['py_callable'], (1, 2, 3), {'kwonly': 4})])
     task.options = {}
     my_action = task.actions[0]
     my_action.execute()
     assert [(1, 2, 3), 4] == got, repr(got)
开发者ID:pydoit,项目名称:doit,代码行数:15,代码来源:test_action.py

示例15: test_method

# 需要导入模块: from doit.task import Task [as 别名]
# 或者: from doit.task.Task import options [as 别名]
 def test_method(self):
     got = []
     class CallMe(object):
         def xxx(self, a, b, changed):
             got.append(a)
             got.append(b)
             got.append(changed)
     task = Task('Fake', [(CallMe().xxx, ('a', 'b'))])
     task.options = {}
     task.dep_changed = ['changed']
     my_action = task.actions[0]
     my_action.execute()
     assert got == ['a', 'b', ['changed']]
开发者ID:pydoit,项目名称:doit,代码行数:15,代码来源:test_action.py


注:本文中的doit.task.Task.options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。