Skip to content

Commit fa9479c

Browse files
committed
Added back the unit test of exclude_from_history
1 parent 00fab10 commit fa9479c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_cmd2.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,30 @@ def test_base_py_interactive(base_app):
792792
m.assert_called_once()
793793

794794

795+
def test_exclude_from_history(base_app, monkeypatch):
796+
# Mock out the os.system call so we don't actually open an editor
797+
m = mock.MagicMock(name='system')
798+
monkeypatch.setattr("os.system", m)
799+
800+
# Run edit command
801+
run_cmd(base_app, 'edit')
802+
803+
# Run history command
804+
run_cmd(base_app, 'history')
805+
806+
# Verify that the history is empty
807+
out = run_cmd(base_app, 'history')
808+
assert out == []
809+
810+
# Now run a command which isn't excluded from the history
811+
run_cmd(base_app, 'help')
812+
# And verify we have a history now ...
813+
out = run_cmd(base_app, 'history')
814+
expected = normalize("""-------------------------[1]
815+
help""")
816+
assert out == expected
817+
818+
795819
def test_base_cmdloop_with_queue():
796820
# Create a cmd2.Cmd() instance and make sure basic settings are like we want for test
797821
app = cmd2.Cmd()

0 commit comments

Comments
 (0)