@@ -2780,6 +2780,45 @@ def test_nonexistent_macro(base_app) -> None:
27802780 assert exception is not None
27812781
27822782
2783+ @pytest .mark .parametrize (
2784+ # The line of text and whether to continue prompting to finish a multiline command.
2785+ ('line' , 'should_continue' ),
2786+ [
2787+ ("" , False ),
2788+ (" " , False ),
2789+ ("help" , False ),
2790+ ("help alias" , False ),
2791+ ("orate" , True ),
2792+ ("orate;" , False ),
2793+ ("orate\n " , False ),
2794+ ("orate\n arg" , True ),
2795+ ("orate\n arg;" , False ),
2796+ ("orate\n arg\n " , False ),
2797+ ("single_mac" , False ), # macro resolution error returns False (no arg passed)
2798+ ("single_mac arg" , False ),
2799+ ("multi_mac" , False ), # macro resolution error returns False (no arg passed)
2800+ ("multi_mac arg" , True ),
2801+ ("multi_mac arg;" , False ),
2802+ ("multi_mac arg\n " , False ),
2803+ ("multi_mac\n arg" , True ),
2804+ ("multi_mac\n arg;" , False ),
2805+ ("multi_mac\n arg\n " , False ),
2806+ ],
2807+ )
2808+ def test_should_continue_multiline (multiline_app : MultilineApp , line : str , should_continue : bool ) -> None :
2809+ mock_buffer = mock .MagicMock ()
2810+ mock_buffer .text = line
2811+
2812+ mock_app = mock .MagicMock ()
2813+ mock_app .current_buffer = mock_buffer
2814+
2815+ run_cmd (multiline_app , "macro create single_mac help {1}" )
2816+ run_cmd (multiline_app , "macro create multi_mac orate {1}" )
2817+
2818+ with mock .patch ('cmd2.cmd2.get_app' , return_value = mock_app ):
2819+ assert multiline_app ._should_continue_multiline () is should_continue
2820+
2821+
27832822@with_ansi_style (ru .AllowStyle .ALWAYS )
27842823def test_perror_style (base_app , capsys ) -> None :
27852824 msg = 'testing...'
0 commit comments