File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1017,14 +1017,13 @@ def _cmdloop(self):
1017
1017
if self .cmdqueue :
1018
1018
# Run command out of cmdqueue if nonempty (populated by load command or commands at invocation)
1019
1019
line = self .cmdqueue .pop (0 )
1020
+
1021
+ if self .echo and line != 'eos' :
1022
+ self .poutput ('{}{}' .format (self .prompt , line ))
1020
1023
else :
1021
1024
# Otherwise, read a command from stdin
1022
1025
line = self .pseudo_raw_input (self .prompt )
1023
1026
1024
- # If echo is on and in the middle of running a script, then echo the line to the output
1025
- if self .echo and self ._current_script_dir is not None :
1026
- self .poutput (line + '\n ' )
1027
-
1028
1027
# Run the command along with all associated pre and post hooks
1029
1028
stop = self .onecmd_plus_hooks (line )
1030
1029
finally :
Original file line number Diff line number Diff line change @@ -1372,7 +1372,8 @@ def test_echo(capsys):
1372
1372
app = cmd2 .Cmd ()
1373
1373
# Turn echo on and pre-stage some commands in the queue, simulating like we are in the middle of a script
1374
1374
app .echo = True
1375
- app .cmdqueue = ['help history' , 'quit' , 'eos' ]
1375
+ command = 'help history'
1376
+ app .cmdqueue = [command , 'quit' , 'eos' ]
1376
1377
app ._script_dir .append ('some_dir' )
1377
1378
1378
1379
assert app ._current_script_dir is not None
@@ -1385,7 +1386,7 @@ def test_echo(capsys):
1385
1386
# Check the output
1386
1387
assert app .cmdqueue == []
1387
1388
assert app ._current_script_dir is None
1388
- assert out .startswith ('help history \n ' + 'history [arg]: lists past commands issued' )
1389
+ assert out .startswith ('{}{} \n ' . format ( app . prompt , command ) + 'history [arg]: lists past commands issued' )
1389
1390
1390
1391
1391
1392
def test_raw_input (base_app ):
You can’t perform that action at this time.
0 commit comments