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


Python task.Task类代码示例

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


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

示例1: test_callable_invalid

 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,代码行数:7,代码来源:test_action.py

示例2: test_save_result

 def test_save_result(self, pdepfile):
     t1 = Task('t_name', None)
     t1.result = "result"
     pdepfile.save_success(t1)
     assert get_md5("result") == pdepfile._get(t1.name, "result:")
     pdepfile.remove_success(t1)
     assert None is pdepfile._get(t1.name, "result:")
开发者ID:agustinhenze,项目名称:doit.debian,代码行数:7,代码来源:test_dependency.py

示例3: test_meta_arg_default_disallowed

 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,代码行数:7,代码来源:test_action.py

示例4: test_no_extra_args

 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,代码行数:8,代码来源:test_action.py

示例5: test_task_options

 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,代码行数:9,代码来源:test_action.py

示例6: test_option_default_allowed

 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,代码行数:9,代码来源:test_action.py

示例7: testSetVerbosity

 def testSetVerbosity(self, depfile):
     output = StringIO.StringIO()
     t = Task('x', None)
     used_verbosity = []
     def my_execute(out, err, verbosity):
         used_verbosity.append(verbosity)
     t.execute = my_execute
     cmds.doit_run(depfile.name, [t], output, verbosity=2)
     assert 2 == used_verbosity[0], used_verbosity
开发者ID:SchuylerGoodman,项目名称:topicalguide,代码行数:9,代码来源:test_cmds.py

示例8: test_both

 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,代码行数:10,代码来源:test_action.py

示例9: test_callable_return_command_str

 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,代码行数:10,代码来源:test_action.py

示例10: test_task_pos_arg

 def test_task_pos_arg(self):
     cmd = "%s %s/myecho.py" % (executable, TEST_PATH)
     cmd += " %(pos)s"
     task = Task('Fake', [cmd], pos_arg='pos')
     task.options = {}
     task.pos_arg_val = ['hi', 'there']
     my_action = task.actions[0]
     assert my_action.execute() is None
     got = my_action.out.strip()
     assert "hi there" == got
开发者ID:pydoit,项目名称:doit,代码行数:10,代码来源:test_action.py

示例11: testSetVerbosity

 def testSetVerbosity(self, depfile):
     output = StringIO.StringIO()
     t = Task('x', None)
     used_verbosity = []
     def my_execute(out, err, verbosity):
         used_verbosity.append(verbosity)
     t.execute = my_execute
     cmd_run = Run(dep_file=depfile.name, task_list=[t])
     cmd_run._execute(output, verbosity=2)
     assert 2 == used_verbosity[0], used_verbosity
开发者ID:swayf,项目名称:doit,代码行数:10,代码来源:test_cmd_run.py

示例12: testSetVerbosity

 def testSetVerbosity(self):
     remove_testdb()
     output = StringIO.StringIO()
     t = Task('x', None)
     used_verbosity = []
     def my_execute(out, err, verbosity):
         used_verbosity.append(verbosity)
     t.execute = my_execute
     cmds.doit_run(TESTDB, [t], output, verbosity=2)
     assert 2 == used_verbosity[0], used_verbosity
开发者ID:jergason,项目名称:topicalguide,代码行数:10,代码来源:test_cmds.py

示例13: test_save_result_dep

 def test_save_result_dep(self, depfile):
     t1 = Task('t1', None)
     t1.result = "result"
     depfile.save_success(t1)
     t2 = Task('t2', None, result_dep=['t1'])
     depfile.save_success(t2)
     assert get_md5(t1.result) == depfile._get("t2", "task:t1")
     t3 = Task('t3', None, task_dep=['t1'])
     depfile.save_success(t3)
     assert None is depfile._get("t3", "task:t1")
开发者ID:jergason,项目名称:topicalguide,代码行数:10,代码来源:test_dependency.py

示例14: testSetVerbosity

 def testSetVerbosity(self, depfile_name):
     output = StringIO()
     t = Task('x', None)
     used_verbosity = []
     def my_execute(out, err, verbosity):
         used_verbosity.append(verbosity)
     t.execute = my_execute
     cmd_run = CmdFactory(Run, backend='dbm', dep_file=depfile_name,
                          task_list=[t])
     cmd_run._execute(output, verbosity=2)
     assert 2 == used_verbosity[0], used_verbosity
开发者ID:JohannesBuchner,项目名称:doit,代码行数:11,代码来源:test_cmd_run.py

示例15: test_keyword_extra_args

 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,代码行数:11,代码来源:test_action.py


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