From 0db91e220517c767e1e81fd37d1dd7ce83fa77b7 Mon Sep 17 00:00:00 2001 From: David Lord Date: Wed, 19 May 2021 10:39:53 -0700 Subject: return resolved name, not original name --- tests/test_commands.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_commands.py b/tests/test_commands.py index 79f87fa..9ebf612 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -285,6 +285,10 @@ def test_aliased_command_canonical_name(runner): def get_command(self, ctx, cmd_name): return push + def resolve_command(self, ctx, args): + _, command, args = super().resolve_command(ctx, args) + return command.name, command, args + cli = AliasedGroup() @cli.command() @@ -296,6 +300,16 @@ def test_aliased_command_canonical_name(runner): assert result.output.startswith("Usage: root push [OPTIONS]") +def test_group_add_command_name(runner): + cli = click.Group("cli") + cmd = click.Command("a", params=[click.Option(["-x"], required=True)]) + cli.add_command(cmd, "b") + # Check that the command is accessed through the registered name, + # not the original name. + result = runner.invoke(cli, ["b"], default_map={"b": {"x": 3}}) + assert result.exit_code == 0 + + def test_unprocessed_options(runner): @click.command(context_settings=dict(ignore_unknown_options=True)) @click.argument("args", nargs=-1, type=click.UNPROCESSED) -- cgit v1.2.1