Skip to content

Commit

Permalink
Add test from #612 for usage error Argument format
Browse files Browse the repository at this point in the history
Adds a test that ensures that when an Argument is formatted into a usage
error, its metavar is used, not its name.
  • Loading branch information
sirosen committed Dec 30, 2016
1 parent 82204dc commit 7b418c3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 7b418c3

Please sign in to comment.