summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGianluca Gippetto <gianluca.gippetto@gmail.com>2021-06-18 18:31:00 +0200
committerDavid Lord <davidism@gmail.com>2022-02-20 08:47:34 -0800
commit144f3701b23186ac8b2277d8f224fd7090366db5 (patch)
treef553ded4345c80d6d8dc0c683e635c35508e5120 /tests
parent08ecfd0e7c238a2444886d239de6d0e9d83530ec (diff)
downloadclick-144f3701b23186ac8b2277d8f224fd7090366db5.tar.gz
Option.show_default now overrides Context.show_default
Previously, it was the opposite.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_options.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_options.py b/tests/test_options.py
index 7367a32..ab230c4 100644
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -643,7 +643,6 @@ def test_option_custom_class_reusable(runner):
# Both of the commands should have the --help option now.
for cmd in (cmd1, cmd2):
-
result = runner.invoke(cmd, ["--help"])
assert "I am a help text" in result.output
assert "you wont see me" not in result.output
@@ -796,6 +795,28 @@ def test_do_not_show_default_empty_multiple():
@pytest.mark.parametrize(
+ ("ctx_value", "opt_value", "expect"),
+ [
+ (None, None, False),
+ (None, False, False),
+ (None, True, True),
+ (False, None, False),
+ (False, False, False),
+ (False, True, True),
+ (True, None, True),
+ (True, False, False),
+ (True, True, True),
+ (False, "one", True),
+ ],
+)
+def test_show_default_precedence(ctx_value, opt_value, expect):
+ ctx = click.Context(click.Command("test"), show_default=ctx_value)
+ opt = click.Option("-a", default=1, help="value", show_default=opt_value)
+ help = opt.get_help_record(ctx)[1]
+ assert ("default:" in help) is expect
+
+
+@pytest.mark.parametrize(
("args", "expect"),
[
(None, (None, None, ())),