From a91a17115cc5aed2f16cb0404a656eb1664dd9ee Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Mon, 9 Nov 2026 05:53:16 -0500 Subject: [PATCH] more test coverage for special_commands/main.py --- changelog.md | 8 +++++ mycli_test/pytests/test_special_main.py | 39 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/changelog.md b/changelog.md index 82cd5279..60661ac5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +Upcoming (TBD) +============== + +Internal +-------- +* Improve test coverage for `packages/special_commands/main.py`. + + v2.30.3 (2026/11/05) ============== diff --git a/mycli_test/pytests/test_special_main.py b/mycli_test/pytests/test_special_main.py index c9e92bd5..4b44e444 100644 --- a/mycli_test/pytests/test_special_main.py +++ b/mycli_test/pytests/test_special_main.py @@ -360,6 +360,45 @@ def test_show_help_lists_only_visible_commands(restore_commands: None) -> None: assert f'Docs index — {DOCS_URL}' in result.postamble +def test_register_backslash_only_alias_omits_slash_variant(restore_commands: None) -> None: + special_commands_main.COMMANDS.clear() + special_commands_main.register_special_command( + lambda: None, + r'\demo', + r'\demo', + 'Demo command', + aliases=[special_commands_main.SpecialCommandAlias(r'\d', case_sensitive=True)], + backslash_only=True, + ) + + assert set(special_commands_main.COMMANDS) == {r'\demo', r'\d'} + alias = special_commands_main.COMMANDS[r'\d'] + assert alias.backslash_only is True + assert alias.hidden is True + assert alias.case_sensitive is True + + +def test_show_help_without_alias(restore_commands: None) -> None: + special_commands_main.COMMANDS.clear() + special_commands_main.register_special_command(lambda: None, 'demo', '/demo', 'Demo command') + + assert special_commands_main.show_help()[0].rows == [('/demo', None, '/demo', 'Demo command')] + + +def test_show_help_preserves_backslash_only_names(restore_commands: None) -> None: + special_commands_main.COMMANDS.clear() + special_commands_main.register_special_command( + lambda: None, + r'\demo', + r'\demo', + 'Demo command', + aliases=[special_commands_main.SpecialCommandAlias(r'\d', case_sensitive=True)], + backslash_only=True, + ) + + assert special_commands_main.show_help()[0].rows == [(r'\demo', r'\d', r'\demo', 'Demo command')] + + def test_show_keyword_help_for_special_command(restore_commands: None) -> None: special_commands_main.COMMANDS.clear() special_commands_main.CASE_SENSITIVE_COMMANDS.clear()