@@ -1187,3 +1187,47 @@ def test_cmdresult(cmdresult_app):
11871187 run_cmd (cmdresult_app , 'negative {}' .format (arg ))
11881188 assert not cmdresult_app ._last_result
11891189 assert cmdresult_app ._last_result == cmd2 .CmdResult ('' , arg )
1190+
1191+
1192+ @pytest .fixture
1193+ def abbrev_app ():
1194+ app = cmd2 .Cmd ()
1195+ app .abbrev = True
1196+ app .stdout = StdOut ()
1197+ return app
1198+
1199+ def test_exclude_from_history (abbrev_app ):
1200+ # Run all variants of run
1201+ run_cmd (abbrev_app , 'run' )
1202+ run_cmd (abbrev_app , 'ru' )
1203+ run_cmd (abbrev_app , 'r' )
1204+
1205+ # Mock out the os.system call so we don't actually open an editor
1206+ m = mock .MagicMock (name = 'system' )
1207+ os .system = m
1208+
1209+ # Run all variants of edit
1210+ run_cmd (abbrev_app , 'edit' )
1211+ run_cmd (abbrev_app , 'edi' )
1212+ run_cmd (abbrev_app , 'ed' )
1213+
1214+ # Run all variants of history
1215+ run_cmd (abbrev_app , 'history' )
1216+ run_cmd (abbrev_app , 'histor' )
1217+ run_cmd (abbrev_app , 'histo' )
1218+ run_cmd (abbrev_app , 'hist' )
1219+ run_cmd (abbrev_app , 'his' )
1220+ run_cmd (abbrev_app , 'hi' )
1221+
1222+ # Verify that the history is empty
1223+ out = run_cmd (abbrev_app , 'history' )
1224+ assert out == []
1225+
1226+ # Now run a command which isn't excluded from the history
1227+ run_cmd (abbrev_app , 'help' )
1228+ # And verify we have a history now ...
1229+ out = run_cmd (abbrev_app , 'history' )
1230+ expected = normalize ("""-------------------------[1]
1231+ help""" )
1232+ assert out == expected
1233+
0 commit comments