Skip to content
Myr

Add test demonstrating an argument decorator can't be reused

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

authored by Gianluca Gippetto · committed by Gianluca Gippetto · parent c77966e · Browse files · 1 file+20 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+20 added−0 removed

  • tests:+20 added−0 removed

1 file+20 added−0 removed

modified:tests/test_arguments.py+20 added
379 unmodified lines
380381 result = runner.invoke(cli, ["arg1", "cmd", "arg2", "subcmd", "--help"])382 assert not result.exception383 assert "Usage: cli ARG1 cmd ARG2 subcmd [OPTIONS]" in result.output384385386def test_when_argument_decorator_is_used_multiple_times_cls_is_preserved():387 class CustomArgument(click.Argument):388 pass389390 reusable_argument = click.argument("art", cls=CustomArgument)391392 @click.command()393 @reusable_argument394 def foo(arg):395 pass396397 @click.command()398 @reusable_argument399 def bar(arg):400 pass401402 assert isinstance(foo.params[0], CustomArgument)403 assert isinstance(bar.params[0], CustomArgument)