本文整理汇总了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)
示例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:")
示例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)
示例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()
示例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
示例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)
示例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
示例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
示例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)
示例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
示例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
示例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
示例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")
示例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
示例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}]