summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-02 19:00:11 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-02 19:00:11 -0500
commitfa9479c228ab498eac8bd91b79bb0b8d04d0be1a (patch)
tree3b5b1d9822b947b854dd753be552a8b37fce8077 /tests/test_cmd2.py
parent00fab107f31962133946e98eadb3dd4be5372947 (diff)
downloadcmd2-git-fa9479c228ab498eac8bd91b79bb0b8d04d0be1a.tar.gz
Added back the unit test of exclude_from_history
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 477d476e..5facd0ac 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -792,6 +792,30 @@ def test_base_py_interactive(base_app):
m.assert_called_once()
+def test_exclude_from_history(base_app, monkeypatch):
+ # Mock out the os.system call so we don't actually open an editor
+ m = mock.MagicMock(name='system')
+ monkeypatch.setattr("os.system", m)
+
+ # Run edit command
+ run_cmd(base_app, 'edit')
+
+ # Run history command
+ run_cmd(base_app, 'history')
+
+ # Verify that the history is empty
+ out = run_cmd(base_app, 'history')
+ assert out == []
+
+ # Now run a command which isn't excluded from the history
+ run_cmd(base_app, 'help')
+ # And verify we have a history now ...
+ out = run_cmd(base_app, 'history')
+ expected = normalize("""-------------------------[1]
+help""")
+ assert out == expected
+
+
def test_base_cmdloop_with_queue():
# Create a cmd2.Cmd() instance and make sure basic settings are like we want for test
app = cmd2.Cmd()