summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2021-05-19 10:39:53 -0700
committerDavid Lord <davidism@gmail.com>2021-05-19 10:49:02 -0700
commit0db91e220517c767e1e81fd37d1dd7ce83fa77b7 (patch)
tree2196bcf99033d23889da55c1735a89c242c06e04 /tests
parent329b1001755452c96dcefcf4a3c799a2463710e0 (diff)
downloadclick-0db91e220517c767e1e81fd37d1dd7ce83fa77b7.tar.gz
return resolved name, not original name
Diffstat (limited to 'tests')
-rw-r--r--tests/test_commands.py14
1 files changed, 14 insertions, 0 deletions
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)