@@ -216,6 +216,29 @@ def test_load_record_transcript(base_app, request):
216216 assert xscript == expected
217217
218218
219+ def test_generate_transcript_stop (capsys ):
220+ # Verify transcript generation stops when a command returns True for stop
221+ app = CmdLineApp ()
222+
223+ # Make a tmp file to use as a transcript
224+ fd , transcript_fname = tempfile .mkstemp (prefix = '' , suffix = '.trn' )
225+ os .close (fd )
226+
227+ # This should run all commands return False for stop
228+ commands = ['help' , 'alias' ]
229+ stop = app ._generate_transcript (commands , transcript_fname )
230+ _ , err = capsys .readouterr ()
231+ assert not stop
232+ assert err .startswith ("2 commands" )
233+
234+ # Since quit returns True for stop, only the first 2 commands will run and stop should be True
235+ commands = ['help' , 'quit' , 'alias' ]
236+ stop = app ._generate_transcript (commands , transcript_fname )
237+ _ , err = capsys .readouterr ()
238+ assert stop
239+ assert err .startswith ("2 commands" )
240+
241+
219242@pytest .mark .parametrize ('expected, transformed' , [
220243 # strings with zero or one slash or with escaped slashes means no regular
221244 # expression present, so the result should just be what re.escape returns.
0 commit comments