Skip to content

Commit

Permalink
add format test for bad argument with metavar
Browse files Browse the repository at this point in the history
  • Loading branch information
LokiHokie committed May 14, 2018
1 parent f21f014 commit f99c8d5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def cmd(arg):
]


def test_formatting_usage_error_metavar(runner):
def test_formatting_usage_error_metavar_missing_arg(runner):
"""
:author: @r-m-n
Including attribution to #612
Expand All @@ -183,6 +183,22 @@ def cmd(arg):
]


def test_formatting_usage_error_metavar_bad_arg(runner):
@click.command()
@click.argument('arg', type=click.INT, metavar='metavar')
def cmd(arg):
pass

result = runner.invoke(cmd, ['3.14'])
assert result.exit_code == 2
assert result.output.splitlines() == [
'Usage: cmd [OPTIONS] metavar',
'Try "cmd --help" for help.',
'',
'Error: Invalid value for "metavar": 3.14 is not a valid integer'
]


def test_formatting_usage_error_nested(runner):
@click.group()
def cmd():
Expand Down

0 comments on commit f99c8d5

Please sign in to comment.