summaryrefslogtreecommitdiff
path: root/tests/test_shell_completion.py
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-10-03 14:35:08 -0700
committerDavid Lord <davidism@gmail.com>2020-10-03 14:35:08 -0700
commit8981a95d4032fb752ffd0b87059d9048e8c996f1 (patch)
treee965c86bd637ffd5d402a5e5b64c3f434d2ee395 /tests/test_shell_completion.py
parent6c8301e0ceeee124dc4ae3a51591c5810dc39840 (diff)
downloadclick-8981a95d4032fb752ffd0b87059d9048e8c996f1.tar.gz
pass extra context settings to completion
Diffstat (limited to 'tests/test_shell_completion.py')
-rw-r--r--tests/test_shell_completion.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py
index 2357cb7..39c0161 100644
--- a/tests/test_shell_completion.py
+++ b/tests/test_shell_completion.py
@@ -14,7 +14,7 @@ from click.types import Path
def _get_completions(cli, args, incomplete):
- comp = ShellComplete(cli, cli.name, "_CLICK_COMPLETE")
+ comp = ShellComplete(cli, {}, cli.name, "_CLICK_COMPLETE")
return comp.get_completions(args, incomplete)
@@ -275,3 +275,17 @@ def test_full_complete(runner, shell, env, expect):
env["_CLI_COMPLETE"] = f"complete_{shell}"
result = runner.invoke(cli, env=env)
assert result.output == expect
+
+
+@pytest.mark.usefixtures("_patch_for_completion")
+def test_context_settings(runner):
+ def complete(ctx, param, incomplete):
+ return ctx.obj["choices"]
+
+ cli = Command("cli", params=[Argument("x", shell_complete=complete)])
+ result = runner.invoke(
+ cli,
+ obj={"choices": ["a", "b"]},
+ env={"COMP_WORDS": "", "COMP_CWORD": "0", "_CLI_COMPLETE": "complete_bash"},
+ )
+ assert result.output == "plain,a\nplain,b\n"