From 460a14254c5ad932e3ebec86e215036562ed3ac5 Mon Sep 17 00:00:00 2001 From: Joshua Cannon <3956745+thejcannon@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:34:03 -0600 Subject: [PATCH] add tests --- tests/test_options.py | 11 +++++++++++ tests/test_termui.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/test_options.py b/tests/test_options.py index b7267c182..d4a015bf7 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -856,6 +856,17 @@ def test_show_default_string(runner): assert "[default: (unlimited)]" in message +def test_string_show_default_shows_custom_string_in_prompt(runner): + @click.command() + @click.option("--arg1", show_default="custom", prompt=True, default="my-default-value") + def cmd(arg1): + pass + + result = runner.invoke(cmd, input="my-input", standalone_mode=False) + assert "(custom)" in result.output + assert "my-default-value" not in result.output + + def test_show_default_with_empty_string(runner): """When show_default is True and default is set to an empty string.""" opt = click.Option(["--limit"], default="", show_default=True) diff --git a/tests/test_termui.py b/tests/test_termui.py index ad9d0a66c..81606fda8 100644 --- a/tests/test_termui.py +++ b/tests/test_termui.py @@ -485,3 +485,14 @@ def cmd(arg1): # is False result = runner.invoke(cmd, input="my-input", standalone_mode=False) assert "my-default-value" not in result.output + + +def test_string_show_default_shows_custom_string_in_prompt(runner): + @click.command() + @click.option("--arg1", show_default="custom", prompt=True, default="my-default-value") + def cmd(arg1): + pass + + result = runner.invoke(cmd, input="my-input", standalone_mode=False) + assert "(custom)" in result.output + assert "my-default-value" not in result.output