def test_should_print_error_when_giving_incorrect_option_for_list_types(
        runner, parameter, expression, message):
    @click.command()
    @click.option('-v', 'values', type=parameter)
    def cli(values):
        click.echo(values)

    result = runner.invoke(cli, ['-v', expression])

    assert_in_output(2, f'These items are not {message}', result)
def test_should_print_error_when_giving_value_is_out_of_limits(
        runner, parameter, value, message):
    @click.command()
    @click.option('-c', 'count', type=parameter)
    def cli(count):
        click.echo(count)

    result = runner.invoke(cli, ['-c', value])

    assert_in_output(2, message, result)
def test_should_print_error_when_giving_incorrect_option_for_simple_types(
        runner, parameter, str_type, param_value):
    @click.command()
    @click.option('-v', 'value', type=parameter)
    def cli(value):
        click.echo(value)

    result = runner.invoke(cli, ['-v', param_value])

    assert_in_output(2, f'{param_value} is not a valid {str_type}', result)