Beispiel #1
0
    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')
Beispiel #2
0
    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'})
Beispiel #3
0
    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')
Beispiel #4
0
    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'})
Beispiel #5
0
    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'})
Beispiel #6
0
    def test_add_validator_without_callable(self, raw_args):
        arg_ = arg.Arg(*raw_args['raw'])

        with pytest.raises(ValueError):
            arg_.add_validator('test')
Beispiel #7
0
    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)