diff options
author | David Lord <davidism@gmail.com> | 2021-03-05 08:46:06 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-03-05 08:46:06 -0800 |
commit | 21a68bd1776248ff071bbfc321d81e9f341b5250 (patch) | |
tree | a00988960c657a8367d0bec4766c9f3644ec0957 /tests/test_context.py | |
parent | 1cb86096124299579156f2c983efe05585f1a01b (diff) | |
download | click-21a68bd1776248ff071bbfc321d81e9f341b5250.tar.gz |
add pass_meta_key decorator
Diffstat (limited to 'tests/test_context.py')
-rw-r--r-- | tests/test_context.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_context.py b/tests/test_context.py index c6aee3c..98f0835 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -4,6 +4,7 @@ import pytest import click from click.core import ParameterSource +from click.decorators import pass_meta_key def test_ensure_context_objects(runner): @@ -151,6 +152,28 @@ def test_context_meta(runner): runner.invoke(cli, [], catch_exceptions=False) +def test_make_pass_meta_decorator(runner): + @click.group() + @click.pass_context + def cli(ctx): + ctx.meta["value"] = "good" + + @cli.command() + @pass_meta_key("value") + def show(value): + return value + + result = runner.invoke(cli, ["show"], standalone_mode=False) + assert result.return_value == "good" + + +def test_make_pass_meta_decorator_doc(): + pass_value = pass_meta_key("value") + assert "the 'value' key from :attr:`click.Context.meta`" in pass_value.__doc__ + pass_value = pass_meta_key("value", doc_description="the test value") + assert "passes the test value" in pass_value.__doc__ + + def test_context_pushing(): rv = [] |