Skip to content
Myr

yN->y/N

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 71da0b4 · Browse files · 3 files+42 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+42 added−1 removed

  • tests:+40 added−0 removed
  • other:+2 added−1 removed

3 files+42 added−1 removed

modified:click/termui.py+1 added-1 removed
105 unmodified lines
106 :param prompt_suffix: a suffix that should be added to the prompt.107 :param show_default: shows or hides the default value in the prompt.108 """109 prompt = _build_prompt(text, prompt_suffix, show_default,110 default and 'Yn' or 'yN')110 default and 'Y/n' or 'y/N')111 while 1:112 try:113 value = visible_prompt_func(prompt).lower().strip()114 except (KeyboardInterrupt, EOFError):
320 unmodified lines
modified:tests/test_utils.py+40 added
69 unmodified lines
70 assert click.format_filename(u'/x/foo.txt') == '/x/foo.txt'71 assert click.format_filename(u'/x/foo.txt', shorten=True) == 'foo.txt'72 assert click.format_filename(b'/x/foo\xff.txt', shorten=True) \73 == u'foo\ufffd.txt'747576def test_prompts(runner):77 @click.command()78 def test():79 if click.confirm('Foo'):80 click.echo('yes!')81 else:82 click.echo('no :(')8384 result = runner.invoke(test, input='y\n')85 assert not result.exception86 assert result.output == 'Foo [y/N]: y\nyes!\n'8788 result = runner.invoke(test, input='\n')89 assert not result.exception90 assert result.output == 'Foo [y/N]: \nno :(\n'9192 result = runner.invoke(test, input='n\n')93 assert not result.exception94 assert result.output == 'Foo [y/N]: n\nno :(\n'9596 @click.command()97 def test_no():98 if click.confirm('Foo', default=True):99 click.echo('yes!')100 else:101 click.echo('no :(')102103 result = runner.invoke(test_no, input='y\n')104 assert not result.exception105 assert result.output == 'Foo [Y/n]: y\nyes!\n'106107 result = runner.invoke(test_no, input='\n')108 assert not result.exception109 assert result.output == 'Foo [Y/n]: \nyes!\n'110111 result = runner.invoke(test_no, input='n\n')112 assert not result.exception113 assert result.output == 'Foo [Y/n]: n\nno :(\n'
modified:CHANGES+1 added
28 unmodified lines
29- Added an :func:`launch` function that launches browsers and applications.30- nargs of -1 for arguments can now be forced to be a single item through31 the required flag. It defaults to not required.32- setting a default for arguments now implicitly makes it non required.33- changed "yN" / "Yn" to "y/N" and "Y/n" in confirmation prompts.3435Version 1.136-----------37
11 unmodified lines