Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Wrap click.Choice's missing message #1000

Merged
merged 1 commit into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion click/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_metavar(self, param):
return '[%s]' % '|'.join(self.choices)

def get_missing_message(self, param):
return 'Choose from %s.' % ', '.join(self.choices)
return 'Choose from:\n\t%s.' % ',\n\t'.join(self.choices)

def convert(self, value, param, ctx):
# Exact match
Expand Down
7 changes: 5 additions & 2 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,11 @@ def cmd(foo):

result = runner.invoke(cmd)
assert result.exit_code == 2
assert 'Error: Missing option "--foo". Choose from foo, bar.' \
in result.output
error, separator, choices = result.output.partition('Choose from')
assert 'Error: Missing option "--foo". ' in error
assert 'Choose from' in separator
assert 'foo' in choices
assert 'bar' in choices


def test_case_insensitive_choice(runner):
Expand Down