Skip to content

Commit a444b46

Browse files
tests: sync expected error message for click 8.4.0 (#133)
`click` `8.4.0` changed the error hint message and prefers long option name over the short one. https://github.com/pallets/click/releases/tag/8.4.0 > The error hint now uses Command.get_help_option_names to pick non-shadowed help option names, so Try '... -h' no longer points to a subcommand option that shadows -h. All surviving names are shown (-h/--help). #2790 #3208 Fixes: #132 Signed-off-by: Stanislav Levin <slev@altlinux.org> Co-authored-by: Dominic Davis-Foster <dominic@davis-foster.co.uk>
1 parent 702bae8 commit a444b46

5 files changed

Lines changed: 24 additions & 1 deletion

tests/test_commands.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from consolekit import CONTEXT_SETTINGS, click_command, click_group
1515
from consolekit.options import colour_option
1616
from consolekit.terminal_colours import ColourTrilean
17-
from consolekit.testing import CliRunner
17+
from consolekit.testing import CliRunner, click_version
1818

1919

2020
@pytest.fixture()
@@ -294,9 +294,23 @@ def test_markdown_help_group_no_args_is_help(
294294
assert result.exit_code == 0
295295

296296

297+
@pytest.mark.parametrize(
298+
"click_version",
299+
[
300+
pytest.param(
301+
"pre_84",
302+
marks=pytest.mark.skipif(click_version >= (8, 4), reason="Output differs on click 8.4"),
303+
),
304+
pytest.param(
305+
"84",
306+
marks=pytest.mark.skipif(click_version < (8, 4), reason="Output differs on click 8.4"),
307+
),
308+
],
309+
)
297310
def test_suggestion_group(
298311
advanced_file_regression: AdvancedFileRegressionFixture,
299312
cli_runner: CliRunner,
313+
click_version: str,
300314
):
301315

302316
@click_group(context_settings={**CONTEXT_SETTINGS, "token_normalize_func": lambda x: x.lower()})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Usage: demo [OPTIONS] COMMAND [ARGS]...
2+
Try 'demo --help' for help.
3+
4+
Error: No such command 'list'.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Usage: demo [OPTIONS] COMMAND [ARGS]...
2+
Try 'demo --help' for help.
3+
4+
Error: No such command 'searh'.
5+
The most similar command is 'search'.

tests/test_commands_/test_suggestion_group_failure.md renamed to tests/test_commands_/test_suggestion_group_pre_84__failure.md

File renamed without changes.

tests/test_commands_/test_suggestion_group_success.md renamed to tests/test_commands_/test_suggestion_group_pre_84__success.md

File renamed without changes.

0 commit comments

Comments
 (0)