@@ -447,15 +447,17 @@ def test_history_with_span_index_error(base_app):
447
447
with pytest .raises (ValueError ):
448
448
base_app .onecmd ('history "hal :"' )
449
449
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;' )
454
456
455
457
fd , fname = tempfile .mkstemp (prefix = '' , suffix = '.txt' )
456
458
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;' ]))
459
461
with open (fname ) as f :
460
462
content = normalize (f .read ())
461
463
assert content == expected
@@ -471,10 +473,12 @@ def test_history_bad_output_file(base_app):
471
473
assert not out
472
474
assert "Error saving" in err [0 ]
473
475
474
- def test_history_edit (base_app , monkeypatch ):
476
+ def test_history_edit (monkeypatch ):
477
+ app = cmd2 .Cmd (multiline_commands = ['alias' ])
478
+
475
479
# Set a fake editor just to make sure we have one. We aren't really
476
480
# going to call it due to the mock
477
- base_app .editor = 'fooedit'
481
+ app .editor = 'fooedit'
478
482
479
483
# Mock out the _run_editor call so we don't actually open an editor
480
484
edit_mock = mock .MagicMock (name = '_run_editor' )
@@ -484,9 +488,11 @@ def test_history_edit(base_app, monkeypatch):
484
488
run_script_mock = mock .MagicMock (name = 'do_run_script' )
485
489
monkeypatch .setattr ("cmd2.Cmd.do_run_script" , run_script_mock )
486
490
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' )
490
496
491
497
# Make sure both functions were called
492
498
edit_mock .assert_called_once ()
0 commit comments