Skip to content
Myr

Merge pull request #787 from ericfrederich/fix_make_pass_decorator

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

Don't arbitrarily strip an argument from make_pass_decorator

authored by David Lord · committed by GitHub · parents 0e088e1, 0aeb6df · Browse files · 2 files+37 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

2 files+37 added−1 removed

  • tests:+36 added−0 removed
  • other:+1 added−1 removed

2 files+37 added−1 removed

modified:click/decorators.py+1 added-1 removed
59 unmodified lines
60 if obj is None:61 raise RuntimeError('Managed to invoke callback without a '62 'context object of type %r existing'63 % object_type.__name__)64 return ctx.invoke(f, obj, *args[1:], **kwargs)64 return ctx.invoke(f, obj, *args, **kwargs)65 return update_wrapper(new_func, f)66 return decorator6768
243 unmodified lines
modified:tests/test_context.py+36 added
201 unmodified lines
202 result = runner.invoke(cli, [])203 assert not result.exception204 assert result.output == 'aha!\n'205 assert called == [True]206207208def test_make_pass_decorator_args(runner):209 """210 Test to check that make_pass_decorator doesn't consume arguments based on211 invocation order.212 """213 class Foo(object):214 title = 'foocmd'215216 pass_foo = click.make_pass_decorator(Foo)217218 @click.group()219 @click.pass_context220 def cli(ctx):221 ctx.obj = Foo()222223 @cli.command()224 @click.pass_context225 @pass_foo226 def test1(foo, ctx):227 click.echo(foo.title)228229 @cli.command()230 @pass_foo231 @click.pass_context232 def test2(ctx, foo):233 click.echo(foo.title)234235 result = runner.invoke(cli, ['test1'])236 assert not result.exception237 assert result.output == 'foocmd\n'238239 result = runner.invoke(cli, ['test2'])240 assert not result.exception241 assert result.output == 'foocmd\n'