Skip to content

Commit 86f5a28

Browse files
committed
Added unit test
1 parent 7e9b567 commit 86f5a28

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_cmd2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,21 @@ def test_onecmd_raw_str_quit(outsim_app):
18531853
assert stop
18541854
assert out == ''
18551855

1856+
def test_onecmd_add_to_history(outsim_app):
1857+
line = "help"
1858+
saved_hist_len = len(outsim_app.history)
1859+
1860+
# Allow command to be added to history
1861+
outsim_app.onecmd(line, add_to_history=True)
1862+
new_hist_len = len(outsim_app.history)
1863+
assert new_hist_len == saved_hist_len + 1
1864+
1865+
saved_hist_len = new_hist_len
1866+
1867+
# Prevent command from being added to history
1868+
outsim_app.onecmd(line, add_to_history=False)
1869+
new_hist_len = len(outsim_app.history)
1870+
assert new_hist_len == saved_hist_len
18561871

18571872
def test_get_all_commands(base_app):
18581873
# Verify that the base app has the expected commands

0 commit comments

Comments
 (0)