Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def returned_arguments_not_given_contain_default_values(self):
# I.e. a Context with args A and B, invoked with no mention of B,
# should result in B existing in the result, with its default value
# intact, and not e.g. None, or the arg not existing.
a = Argument('name', kind=str)
b = Argument('age', default=7)
c = Context('mytask', args=(a, b))
Parser((c,)).parse_argv(['mytask', '--name', 'blah'])
eq_(c.args['age'].value, 7)
def may_validate_on_set(self):
with raises(ValueError):
Argument("a", kind=int).value = "five"
def can_declare_positional(self):
assert Argument(name="foo", positional=True).positional is True
def no_ambiguity_with_flaglike_value_if_option_val_was_given(self):
p = self._parser((
Argument('foo', optional=True),
Argument('bar', kind=bool)
))
# This should NOT raise a ParseError.
result = self._parse("--foo hello --bar", p)
eq_(result[0].args['foo'].value, 'hello')
eq_(result[0].args['bar'].value, True)
def defaults_to_str(self):
assert Argument("a").kind == str
def bool_implies_no_value_needed(self):
assert not Argument(name="a", kind=bool).takes_value
def _basic(self):
arg = Argument('pos', positional=True)
mytask = Context(name='mytask', args=[arg])
return Parser(contexts=[mytask])
def invalid_flaglike_value_is_stored_as_value(self):
self._parser((Argument("foo", optional=True),))
result = self._parse("--foo --bar")
assert result[0].args["foo"].value == "--bar"
def unfilled_posargs(self):
p = self._parser(
(
Argument("foo", optional=True),
Argument("bar", positional=True),
)
)
self._test_for_ambiguity("--foo uhoh", p)
.. versionadded:: 1.0
"""
# Arguments pertaining specifically to invocation as 'invoke' itself
# (or as other arbitrary-task-executing programs, like 'fab')
return [
Argument(
names=("collection", "c"),
help="Specify collection name to load.",
),
Argument(
names=("no-dedupe",),
kind=bool,
default=False,
help="Disable task deduplication.",
),
Argument(
names=("search-root", "r"),
help="Change root directory used for finding task modules.",
),