From 7b418c35bf336d1cb3d4b080b4e6a78ab992a4ac Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Fri, 30 Dec 2016 17:27:01 -0600 Subject: [PATCH] Add test from #612 for usage error Argument format Adds a test that ensures that when an Argument is formatted into a usage error, its metavar is used, not its name. --- tests/test_formatting.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_formatting.py b/tests/test_formatting.py index 4c1c49131..b7a88f073 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -163,6 +163,26 @@ def cmd(arg): ] +def test_formatting_usage_error_metavar(runner): + """ + :author: @r-m-n + Including attribution to #612 + """ + @click.command() + @click.argument('arg', metavar='metavar') + def cmd(arg): + pass + + result = runner.invoke(cmd, []) + assert result.exit_code == 2 + assert result.output.splitlines() == [ + 'Usage: cmd [OPTIONS] metavar', + 'Try "cmd --help" for help.', + '', + 'Error: Missing argument "metavar".' + ] + + def test_formatting_usage_error_nested(runner): @click.group() def cmd():