コード例 #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
ファイル: parser_argument.py プロジェクト: pyinvoke/invoke
 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
ファイル: parser_argument.py プロジェクト: pyinvoke/invoke
 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
コード例 #6
0
 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
ファイル: executor.py プロジェクト: yonggeshidai/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
    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
ファイル: argument.py プロジェクト: msabramo/invoke
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     eq_(a.raw_value, 'foo')
コード例 #10
0
ファイル: argument.py プロジェクト: offbyone/invoke
 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
ファイル: parser_argument.py プロジェクト: yzdx0000/invoke
 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
ファイル: argument.py プロジェクト: hirokiky/invoke
 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
ファイル: parser_argument.py プロジェクト: pyinvoke/invoke
 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
ファイル: argument.py プロジェクト: offbyone/invoke
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     assert a.raw_value == 'foo'
コード例 #17
0
ファイル: parser_argument.py プロジェクト: yzdx0000/invoke
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument("a")
     a.value = "foo"
     assert a.raw_value == "foo"
コード例 #18
0
ファイル: parser_argument.py プロジェクト: pyinvoke/invoke
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument("a")
     a.value = "foo"
     assert a.raw_value == "foo"
コード例 #19
0
ファイル: argument.py プロジェクト: techniq/invoke
 def available_as_dot_raw_value(self):
     "available as .raw_value"
     a = Argument('a')
     a.value = 'foo'
     eq_(a.raw_value, 'foo')
コード例 #20
0
ファイル: parser_argument.py プロジェクト: yzdx0000/invoke
 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
ファイル: argument.py プロジェクト: msabramo/invoke
 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
ファイル: parser_argument.py プロジェクト: pyinvoke/invoke
 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
ファイル: argument.py プロジェクト: hirokiky/invoke
 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
ファイル: argument.py プロジェクト: hirokiky/invoke
 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
ファイル: parser_argument.py プロジェクト: yzdx0000/invoke
 def untransformed_appears_as_dot_value(self):
     "untransformed, appears as .value"
     a = Argument("a", kind=str)
     a.value = "foo"
     assert a.value == "foo"