@@ -447,15 +447,17 @@ def test_history_with_span_index_error(base_app):
447447 with pytest .raises (ValueError ):
448448 base_app .onecmd ('history "hal :"' )
449449
450- def test_history_output_file (base_app ):
451- run_cmd (base_app , 'help' )
452- run_cmd (base_app , 'shortcuts' )
453- run_cmd (base_app , 'help history' )
450+ def test_history_output_file ():
451+ app = cmd2 .Cmd (multiline_commands = ['alias' ])
452+ run_cmd (app , 'help' )
453+ run_cmd (app , 'shortcuts' )
454+ run_cmd (app , 'help history' )
455+ run_cmd (app , 'alias create my_alias history;' )
454456
455457 fd , fname = tempfile .mkstemp (prefix = '' , suffix = '.txt' )
456458 os .close (fd )
457- run_cmd (base_app , 'history -o "{}"' .format (fname ))
458- expected = normalize ('\n ' .join (['help' , 'shortcuts' , 'help history' ]))
459+ run_cmd (app , 'history -o "{}"' .format (fname ))
460+ expected = normalize ('\n ' .join (['help' , 'shortcuts' , 'help history' , 'alias create my_alias history;' ]))
459461 with open (fname ) as f :
460462 content = normalize (f .read ())
461463 assert content == expected
@@ -471,10 +473,12 @@ def test_history_bad_output_file(base_app):
471473 assert not out
472474 assert "Error saving" in err [0 ]
473475
474- def test_history_edit (base_app , monkeypatch ):
476+ def test_history_edit (monkeypatch ):
477+ app = cmd2 .Cmd (multiline_commands = ['alias' ])
478+
475479 # Set a fake editor just to make sure we have one. We aren't really
476480 # going to call it due to the mock
477- base_app .editor = 'fooedit'
481+ app .editor = 'fooedit'
478482
479483 # Mock out the _run_editor call so we don't actually open an editor
480484 edit_mock = mock .MagicMock (name = '_run_editor' )
@@ -484,9 +488,11 @@ def test_history_edit(base_app, monkeypatch):
484488 run_script_mock = mock .MagicMock (name = 'do_run_script' )
485489 monkeypatch .setattr ("cmd2.Cmd.do_run_script" , run_script_mock )
486490
487- # Run help command just so we have a command in history
488- run_cmd (base_app , 'help' )
489- run_cmd (base_app , 'history -e 1' )
491+ # Put commands in history
492+ run_cmd (app , 'help' )
493+ run_cmd (app , 'alias create my_alias history;' )
494+
495+ run_cmd (app , 'history -e 1:2' )
490496
491497 # Make sure both functions were called
492498 edit_mock .assert_called_once ()
0 commit comments