Skip to content
Myr

Add test for make_pass_decorator arg handling

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

This adds a simple test case which ensures that `make_pass_decorator` doesn't consume arguments if it's called out of order.

authored by Stephen Rosen · committed by Stephen Rosen · parent 2069768 · Browse files · 1 file+36 added−0 removed
This commit

State

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

Diff stats

1 file+36 added−0 removed

  • tests:+36 added−0 removed

1 file+36 added−0 removed

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'