diff --git a/tests/test_formatting.py b/tests/test_formatting.py index fa0385cfa..4c1c49131 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -174,9 +174,41 @@ def foo(bar): click.echo('foo:' + bar) result = runner.invoke(cmd, ['foo']) + assert result.exit_code == 2 assert result.output.splitlines() == [ 'Usage: cmd foo [OPTIONS] BAR', 'Try "cmd foo --help" for help.', '', 'Error: Missing argument "bar".' ] + + +def test_formatting_usage_error_no_help(runner): + @click.command(add_help_option=False) + @click.argument('arg') + def cmd(arg): + click.echo('arg:' + arg) + + result = runner.invoke(cmd, []) + assert result.exit_code == 2 + assert result.output.splitlines() == [ + 'Usage: cmd [OPTIONS] ARG', + '', + 'Error: Missing argument "arg".' + ] + + +def test_formatting_usage_custom_help(runner): + @click.command(context_settings=dict(help_option_names=['--man'])) + @click.argument('arg') + def cmd(arg): + click.echo('arg:' + arg) + + result = runner.invoke(cmd, []) + assert result.exit_code == 2 + assert result.output.splitlines() == [ + 'Usage: cmd [OPTIONS] ARG', + 'Try "cmd --man" for help.', + '', + 'Error: Missing argument "arg".' + ]