def test_outpu_raw_required_with_value_in_current_kwargs_input( self, raw_args): arg_ = arg.Arg(*raw_args['raw_required_without_default']) current_kwargs = {'name': 'value'} output = arg_.output(current_kwargs, {'name': 'other'}) assert output == ('name', 'other')
def test_output_raw_required_without_default(self, raw_args): arg_ = arg.Arg(*raw_args['raw_required_without_default']) output = arg_.output({}, {'name': 'value'}) assert output == ('name', 'value') with pytest.raises(RequiredArgMissingError): arg_.output({}, {'other': 'other'})
def test_output_raw_required_with_default(self, raw_args): arg_ = arg.Arg(*raw_args['raw_required_with_default']) output = arg_.output({}, {'name': 'value'}) assert output == ('name', 'value') output = arg_.output({}, {'other': 'other'}) assert output == ('name', 'default')
def test_add_validator_with_callable(self, raw_args): def raise_validator(arg, value): raise ValueError arg_ = arg.Arg(*raw_args['raw']) arg_.add_validator(raise_validator) with pytest.raises(ValueError): arg_.output({}, {'name': 'value'})
def test_output_raw_with_alias(self, raw_args): arg_ = arg.Arg(*raw_args['raw_with_alias']) input_kwargs = {'alias': 'value', 'other': 'other'} output = arg_.output({}, input_kwargs) assert output == ('alias', 'value') assert input_kwargs == {'alias': 'value', 'other': 'other'} with pytest.raises(RequiredArgMissingError): arg_.output({}, {'name': 'value'})
def test_add_validator_without_callable(self, raw_args): arg_ = arg.Arg(*raw_args['raw']) with pytest.raises(ValueError): arg_.add_validator('test')
def test_output_raw_not_required_without_default(self, raw_args): arg_ = arg.Arg(*raw_args['raw_not_required_without_default']) output = arg_.output({}, {'other': 'other'}) assert output == ('name', utils.NoInput)