@@ -1544,6 +1544,13 @@ def test_help_verbose_with_fake_command(capsys) -> None:
15441544 assert cmds [1 ] not in out
15451545
15461546
1547+ def test_ipy_help (base_app : cmd2 .Cmd ) -> None :
1548+ """Verify that help for ipy builds its parser and displays correctly."""
1549+ out , err = run_cmd (base_app , "help ipy" )
1550+ assert "Run an interactive IPython shell." in out
1551+ assert not err
1552+
1553+
15471554def test_render_columns_no_strs (help_app : HelpApp ) -> None :
15481555 no_strs = []
15491556 result = help_app .render_columns (no_strs )
@@ -4297,6 +4304,20 @@ class SynonymApp(cmd2.cmd2.Cmd):
42974304 assert synonym_parser is help_parser
42984305
42994306
4307+ def test_command_parsers_contains () -> None :
4308+ class SampleApp (cmd2 .Cmd ):
4309+ def do_non_argparse (self , args : str ) -> None :
4310+ """Plain command without an argparse decorator."""
4311+
4312+ app = SampleApp ()
4313+
4314+ # Argparse-based command returns True
4315+ assert app .do_help in app .command_parsers
4316+
4317+ # Non-argparse command returns False
4318+ assert app .do_non_argparse not in app .command_parsers
4319+
4320+
43004321def test_custom_completekey_ctrl_k ():
43014322 from prompt_toolkit .keys import Keys
43024323
@@ -4805,25 +4826,19 @@ def test_bracketed_paste_multiple_commands(base_app) -> None:
48054826 sys .platform .startswith ("win" ),
48064827 reason = "Don't have a real Windows console with how we are currently running tests in GitHub Actions" ,
48074828)
4808- def test_bracketed_paste_multiline_command () -> None :
4829+ def test_bracketed_paste_multiline_command (multiline_app ) -> None :
48094830 """Test pasting multiline command awaiting terminator."""
4810-
4811- class MultilineApp (cmd2 .Cmd ):
4812- def __init__ (self ) -> None :
4813- super ().__init__ (multiline_commands = ["sql" ])
4814-
4815- app = MultilineApp ()
48164831 with create_pipe_input () as pipe_input :
4817- app .main_session = PromptSession (
4832+ multiline_app .main_session = PromptSession (
48184833 input = pipe_input ,
48194834 output = DummyOutput (),
4820- key_bindings = app .main_session .key_bindings ,
4821- multiline = app .main_session .multiline ,
4822- prompt_continuation = app .main_session .prompt_continuation ,
4835+ key_bindings = multiline_app .main_session .key_bindings ,
4836+ multiline = multiline_app .main_session .multiline ,
4837+ prompt_continuation = multiline_app .main_session .prompt_continuation ,
48234838 )
48244839
4825- pipe_input .send_text ("\x1b [200~sql select 1\n from table ;\n help\n \x1b [201~" )
4826- line1 = app ._read_command_line ("prompt> " )
4827- assert line1 == "sql select 1\n from table ;"
4828- line2 = app ._read_command_line ("prompt> " )
4840+ pipe_input .send_text ("\x1b [200~orate line 1\n line 2 ;\n help\n \x1b [201~" )
4841+ line1 = multiline_app ._read_command_line ("prompt> " )
4842+ assert line1 == "orate line 1\n line 2 ;"
4843+ line2 = multiline_app ._read_command_line ("prompt> " )
48294844 assert line2 == "help"
0 commit comments