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(myarg, otherarg, optval): 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')) def optional_values_use_brackets(self): eq_(self.tasked.help_for('--optval'), ("-p [STRING], --optval[=STRING]", "")) 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'))
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')
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', '')
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])
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'))
def true_default_args(self): c = Context(args=(Argument("truthy", kind=bool, default=True),)) assert c.help_for("--truthy") == ("--[no-]truthy", "")
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] )
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
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'))
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", "")
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", "")
def true_default_args(self): c = Context(args=(Argument('truthy', kind=bool, default=True),)) eq_(c.help_for('--truthy'), ('--[no-]truthy', ''))
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', '')
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'))
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")