summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-21 18:24:14 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-21 18:24:14 -0400
commit86f5a2886cc14fd18933e0a201e064ac7e6fd2d1 (patch)
treed37d0b921522eb042ebdc32b9a92e2c4594ae7c7 /tests/test_cmd2.py
parent7e9b56789ceb05d23b8d61e619b53f1a1fda111d (diff)
downloadcmd2-git-86f5a2886cc14fd18933e0a201e064ac7e6fd2d1.tar.gz
Added unit test
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 4a9dca31..01e6e271 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1853,6 +1853,21 @@ def test_onecmd_raw_str_quit(outsim_app):
assert stop
assert out == ''
+def test_onecmd_add_to_history(outsim_app):
+ line = "help"
+ saved_hist_len = len(outsim_app.history)
+
+ # Allow command to be added to history
+ outsim_app.onecmd(line, add_to_history=True)
+ new_hist_len = len(outsim_app.history)
+ assert new_hist_len == saved_hist_len + 1
+
+ saved_hist_len = new_hist_len
+
+ # Prevent command from being added to history
+ outsim_app.onecmd(line, add_to_history=False)
+ new_hist_len = len(outsim_app.history)
+ assert new_hist_len == saved_hist_len
def test_get_all_commands(base_app):
# Verify that the base app has the expected commands