Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thejcannon committed Jan 6, 2025
1 parent 195ebba commit 460a142
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 460a142

Please sign in to comment.