本文整理汇总了Python中invoke.parser.Context.help_for方法的典型用法代码示例。如果您正苦于以下问题:Python Context.help_for方法的具体用法?Python Context.help_for怎么用?Python Context.help_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoke.parser.Context
的用法示例。
在下文中一共展示了Context.help_for方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: true_default_args
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def true_default_args(self):
c = Context(args=(Argument('truthy', kind=bool, default=True),))
assert c.help_for('--truthy') == ('--[no-]truthy', '')
示例2: _assert_order
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def _assert_order(self, name_tuples, expected_flag_order):
c = Context(args=[Argument(names=x) for x in name_tuples])
expected = [c.help_for(x) for x in expected_flag_order]
assert c.help_tuples() == expected
示例3: setup
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
class help_for:
def setup(self):
# Normal, non-task/collection related Context
self.vanilla = Context(args=(
Argument('foo'),
Argument('bar', help="bar the baz")
))
# Task/Collection generated Context
# (will expose flags n such)
@task(help={'otherarg': 'other help'}, optional=['optval'])
def mytask(c, myarg, otherarg, optval, intval=5):
pass
col = Collection(mytask)
self.tasked = col.to_contexts()[0]
def raises_ValueError_for_non_flag_values(self):
with raises(ValueError):
self.vanilla.help_for('foo')
def vanilla_no_helpstr(self):
assert self.vanilla.help_for('--foo') == ("--foo=STRING", "")
def vanilla_with_helpstr(self):
result = self.vanilla.help_for('--bar')
assert result == ("--bar=STRING", "bar the baz")
def task_driven_with_helpstr(self):
result = self.tasked.help_for('--otherarg')
assert result == ("-o STRING, --otherarg=STRING", "other help")
# Yes, the next 3 tests are identical in form, but technically they
# test different behaviors. HERPIN' AN' DERPIN'
def task_driven_no_helpstr(self):
result = self.tasked.help_for('--myarg')
assert result == ("-m STRING, --myarg=STRING", "")
def short_form_before_long_form(self):
result = self.tasked.help_for('--myarg')
assert result == ("-m STRING, --myarg=STRING", "")
def equals_sign_for_long_form_only(self):
result = self.tasked.help_for('--myarg')
assert result == ("-m STRING, --myarg=STRING", "")
def kind_to_placeholder_map(self):
# Strings
helpfor = self.tasked.help_for('--myarg')
assert helpfor == ("-m STRING, --myarg=STRING", "")
# Ints
helpfor = self.tasked.help_for('--intval')
assert helpfor == ("-i INT, --intval=INT", "")
# TODO: others
def shortflag_inputs_work_too(self):
m = self.tasked.help_for('-m')
myarg = self.tasked.help_for('--myarg')
assert m == myarg
def optional_values_use_brackets(self):
result = self.tasked.help_for('--optval')
assert result == ("-p [STRING], --optval[=STRING]", "")
def underscored_args(self):
c = Context(args=(Argument('i_have_underscores', help='yup'),))
result = c.help_for('--i-have-underscores')
assert result == ('--i-have-underscores=STRING', 'yup')
def true_default_args(self):
c = Context(args=(Argument('truthy', kind=bool, default=True),))
assert c.help_for('--truthy') == ('--[no-]truthy', '')
示例4: underscored_args
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def underscored_args(self):
c = Context(args=(Argument('i_have_underscores', help='yup'),))
result = c.help_for('--i-have-underscores')
assert result == ('--i-have-underscores=STRING', 'yup')
示例5: _assert_order
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def _assert_order(self, name_tuples, expected_flag_order):
ctx = Context(args=[Argument(names=x) for x in name_tuples])
return eq_(
ctx.help_tuples(),
[ctx.help_for(x) for x in expected_flag_order]
)
示例6: underscored_args
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def underscored_args(self):
c = Context(args=(Argument('i_have_underscores', help='yup'),))
eq_(c.help_for('--i-have-underscores'), ('--i-have-underscores=STRING', 'yup'))
示例7: setup
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
class help_for:
def setup(self):
# Normal, non-task/collection related Context
self.vanilla = Context(args=(
Argument('foo'),
Argument('bar', help="bar the baz")
))
# Task/Collection generated Context
# (will expose flags n such)
@task(help={'otherarg': 'other help'})
def mytask(myarg, otherarg):
pass
col = Collection(mytask)
self.tasked = col.to_contexts()[0]
@raises(ValueError)
def raises_ValueError_for_non_flag_values(self):
self.vanilla.help_for('foo')
def vanilla_no_helpstr(self):
eq_(
self.vanilla.help_for('--foo'),
("--foo=STRING", "")
)
def vanilla_with_helpstr(self):
eq_(
self.vanilla.help_for('--bar'),
("--bar=STRING", "bar the baz")
)
def task_driven_with_helpstr(self):
eq_(
self.tasked.help_for('--otherarg'),
("-o STRING, --otherarg=STRING", "other help")
)
# Yes, the next 3 tests are identical in form, but technically they
# test different behaviors. HERPIN' AN' DERPIN'
def task_driven_no_helpstr(self):
eq_(
self.tasked.help_for('--myarg'),
("-m STRING, --myarg=STRING", "")
)
def short_form_before_long_form(self):
eq_(
self.tasked.help_for('--myarg'),
("-m STRING, --myarg=STRING", "")
)
def equals_sign_for_long_form_only(self):
eq_(
self.tasked.help_for('--myarg'),
("-m STRING, --myarg=STRING", "")
)
def kind_to_placeholder_map(self):
# str=STRING, int=INT, etc etc
skip()
def shortflag_inputs_work_too(self):
eq_(self.tasked.help_for('-m'), self.tasked.help_for('--myarg'))
示例8: true_default_args
# 需要导入模块: from invoke.parser import Context [as 别名]
# 或者: from invoke.parser.Context import help_for [as 别名]
def true_default_args(self):
c = Context(args=(Argument("truthy", kind=bool, default=True),))
assert c.help_for("--truthy") == ("--[no-]truthy", "")