Skip to content
Myr

Merge pull request #999 from kporangehat/invoke_with_prog_name

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

Fix #616: allow setting prog_name as extra in CliRunner.invoke

authored by Dan Sully · committed by GitHub · parents 43cb986, 2bc3b2c · Browse files · 2 files+17 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

2 files+17 added−2 removed

  • tests:+11 added−0 removed
  • other:+6 added−2 removed

2 files+17 added−2 removed

modified:click/testing.py+6 added-2 removed
316 unmodified lines
317 if isinstance(args, string_types):318 args = shlex.split(args)319320 try:321 cli.main(args=args or (),322 prog_name=self.get_default_prog_name(cli), **extra)321 prog_name = extra.pop("prog_name")322 except KeyError:323 prog_name = self.get_default_prog_name(cli)324325 try:326 cli.main(args=args or (), prog_name=prog_name, **extra)327 except SystemExit as e:328 exc_info = sys.exc_info()329 exit_code = e.code330 if exit_code is None:
44 unmodified lines
modified:tests/test_testing.py+11 added
244 unmodified lines
245 runner = CliRunner()246 result = runner.invoke(cli_args, args=args)247 assert result.exit_code == 0248 assert result.output == expected_output249250251def test_setting_prog_name_in_extra():252 @click.command()253 def cli():254 click.echo("ok")255256 runner = CliRunner()257 result = runner.invoke(cli, prog_name="foobar")258 assert not result.exception259 assert result.output == 'ok\n'