示例#1
0
 def list_kind_triggers_append_instead_of_overwrite(self):
     # TODO: when put this way it makes the API look pretty strange;
     # maybe a sign we should switch to explicit setter methods
     # (selected on kind, perhaps) instead of using an implicit setter
     a = Argument('mylist', kind=list)
     assert a.value == []
     a.value = 'val1'
     assert a.value == ['val1']
     a.value = 'val2'
     assert a.value == ['val1', 'val2']
示例#2
0
 def list_kind_triggers_append_instead_of_overwrite(self):
     # TODO: when put this way it makes the API look pretty strange;
     # maybe a sign we should switch to explicit setter methods
     # (selected on kind, perhaps) instead of using an implicit setter
     a = Argument("mylist", kind=list)
     assert a.value == []
     a.value = "val1"
     assert a.value == ["val1"]
     a.value = "val2"
     assert a.value == ["val1", "val2"]
示例#3
0
 def incrementable_True_triggers_increment_of_default(self):
     a = Argument('verbose', kind=int, default=0, incrementable=True)
     assert a.value == 0
     # NOTE: parser currently just goes "Argument.takes_value is false?
     # Gonna stuff True/False in there." So this looks pretty silly out
     # of context (as with list-types above.)
     a.value = True
     assert a.value == 1
     for _ in range(4):
         a.value = True
     assert a.value == 5
示例#4
0
 def incrementable_True_triggers_increment_of_default(self):
     a = Argument("verbose", kind=int, default=0, incrementable=True)
     assert a.value == 0
     # NOTE: parser currently just goes "Argument.takes_value is false?
     # Gonna stuff True/False in there." So this looks pretty silly out
     # of context (as with list-types above.)
     a.value = True
     assert a.value == 1
     for _ in range(4):
         a.value = True
     assert a.value == 5
示例#5
0
文件: executor.py 项目: fabric/fabric
 def hosts_flag_still_triggers_parameterization(self):
     body = Mock(pre=[], post=[])
     coll = Collection(mytask=InvokeTask(body))
     hosts = Argument(name="hosts")
     hosts.value = "host1,host2,host3"
     core_args = ParseResult([ParserContext(args=[hosts])])
     Executor(coll, core=core_args).execute("mytask")
     assert body.call_count == 3
 def hosts_flag_still_triggers_parameterization(self):
     body = Mock(pre=[], post=[])
     coll = Collection(mytask=InvokeTask(body))
     hosts = Argument(name="hosts")
     hosts.value = "host1,host2,host3"
     core_args = ParseResult([ParserContext(args=[hosts])])
     Executor(coll, core=core_args).execute("mytask")
     assert body.call_count == 3
示例#7
0
def _get_executor(hosts_flag=None, hosts_kwarg=None, post=None, remainder=""):
    post_tasks = []
    if post is not None:
        post_tasks.append(post)
    hosts = Argument(name="hosts")
    if hosts_flag is not None:
        hosts.value = hosts_flag
    core_args = ParseResult([ParserContext(args=[hosts])])
    core_args.remainder = remainder
    task = Mock(pre=[], post=[])
    coll = Collection(mytask=Task(task, post=post_tasks, hosts=hosts_kwarg))
    return task, Executor(coll, core=core_args)
示例#8
0
文件: executor.py 项目: fabric/fabric
def _get_executor(hosts_flag=None, hosts_kwarg=None, post=None, remainder=""):
    post_tasks = []
    if post is not None:
        post_tasks.append(post)
    hosts = Argument(name="hosts")
    if hosts_flag is not None:
        hosts.value = hosts_flag
    core_args = ParseResult([ParserContext(args=[hosts])])
    core_args.remainder = remainder
    body = Mock(pre=[], post=[])
    task = Task(body, post=post_tasks, hosts=hosts_kwarg)
    coll = Collection(mytask=task)
    return body, Executor(coll, core=core_args)
示例#9
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     eq_(a.raw_value, 'foo')
示例#10
0
 def transformed_appears_as_dot_value_with_original_as_raw_value(self):
     "transformed, modified value is .value, original is .raw_value"
     a = Argument('a', kind=int)
     a.value = '5'
     assert a.value == 5
     assert a.raw_value == '5'
示例#11
0
 def transformed_appears_as_dot_value_with_original_as_raw_value(self):
     "transformed, modified value is .value, original is .raw_value"
     a = Argument('a', kind=int)
     a.value = '5'
     assert a.value == 5
     assert a.raw_value == '5'
示例#12
0
 def untransformed_appears_as_dot_value(self):
     "untransformed, appears as .value"
     a = Argument('a', kind=str)
     a.value = 'foo'
     assert a.value == 'foo'
示例#13
0
 def non_list_kind_tests_for_None_value(self):
     arg = Argument("a")
     assert not arg.got_value
     arg.value = "something"
     assert arg.got_value
示例#14
0
 def untransformed_appears_as_dot_value(self):
     "untransformed, appears as .value"
     a = Argument("a", kind=str)
     a.value = "foo"
     eq_(a.value, "foo")
示例#15
0
 def non_list_kind_tests_for_None_value(self):
     arg = Argument("a")
     assert not arg.got_value
     arg.value = "something"
     assert arg.got_value
示例#16
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     assert a.raw_value == 'foo'
示例#17
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument("a")
     a.value = "foo"
     assert a.raw_value == "foo"
示例#18
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument("a")
     a.value = "foo"
     assert a.raw_value == "foo"
示例#19
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     eq_(a.raw_value, 'foo')
示例#20
0
 def list_kind_test_for_empty_list_value(self):
     arg = Argument("a", kind=list)
     assert not arg.got_value
     arg.value = "append-me"
     assert arg.got_value
示例#21
0
 def untransformed_appears_as_dot_value(self):
     "untransformed, appears as .value"
     a = Argument('a', kind=str)
     a.value = 'foo'
     eq_(a.value, 'foo')
示例#22
0
 def list_kind_test_for_empty_list_value(self):
     arg = Argument("a", kind=list)
     assert not arg.got_value
     arg.value = "append-me"
     assert arg.got_value
示例#23
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument("a")
     a.value = "foo"
     eq_(a.raw_value, "foo")
示例#24
0
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     assert a.raw_value == 'foo'
示例#25
0
 def transformed_appears_as_dot_value_with_original_as_raw_value(self):
     "transformed, modified value is .value, original is .raw_value"
     a = Argument("a", kind=int)
     a.value = "5"
     eq_(a.value, 5)
     eq_(a.raw_value, "5")
示例#26
0
 def untransformed_appears_as_dot_value(self):
     "untransformed, appears as .value"
     a = Argument("a", kind=str)
     a.value = "foo"
     assert a.value == "foo"