Skip to content
Myr

Merge branch '6.x-maintenance'

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

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 6f4eb1e, ebcbef9 · Browse files · 3 files+25 added−2 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+25 added−2 removed

  • tests:+22 added−0 removed
  • other:+3 added−2 removed

3 files+25 added−2 removed

modified:click/core.py+2 added-2 removed
1565 unmodified lines
1566 possible_names.append(split_opt(decl))1567 opts.append(decl)15681569 if name is None and possible_names:1570 possible_names.sort(key=lambda x: len(x[0]))1571 name = possible_names[-1][1].replace('-', '_').lower()1570 possible_names.sort(key=lambda x: -len(x[0])) # group long options first1571 name = possible_names[0][1].replace('-', '_').lower()1572 if not isidentifier(name):1573 name = None15741575 if name is None:
190 unmodified lines
modified:tests/test_options.py+22 added
333 unmodified lines
334 result = runner.invoke(cli_alt, ['--no-warnings'])335 assert result.output == 'False\n'336 result = runner.invoke(cli_alt, ['-w'])337 assert result.output == 'True\n'338339@pytest.mark.parametrize('option_args,expected', [340 (['--aggressive', '--all', '-a'], 'aggressive'),341 (['--first', '--second', '--third', '-a', '-b', '-c'], 'first'),342 (['--apple', '--banana', '--cantaloupe', '-a', '-b', '-c'], 'apple'),343 (['--cantaloupe', '--banana', '--apple', '-c', '-b', '-a'], 'cantaloupe'),344 (['-a', '-b', '-c'], 'a'),345 (['-c', '-b', '-a'], 'c'),346 (['-a', '--apple', '-b', '--banana', '-c', '--cantaloupe'], 'apple'),347 (['-c', '-a', '--cantaloupe', '-b', '--banana', '--apple'], 'cantaloupe'),348])349def test_multiple_long_options(runner, option_args, expected):350 @click.command()351 @click.option(*option_args, is_flag=True)352 def cmd(**kwargs):353 click.echo(str(kwargs[expected]))354355 assert cmd.params[0].name == expected356357 for form in option_args:358 result = runner.invoke(cmd, [form])359 assert result.output == 'True\n'
modified:CHANGES+1 added
34 unmodified lines
35 #728.36- Fix bug in test runner when calling ``sys.exit`` with ``None``. See #739.37- Fix crash on Windows console, see #744.38- Fix bashcompletion on chained commands. See #754.39- Fix option naming routine to match documentation. See #7934041Version 6.742-----------43
342 unmodified lines