summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py3
-rw-r--r--tests/test_cmd2.py51
-rw-r--r--tests/transcripts/from_cmdloop.txt18
3 files changed, 28 insertions, 44 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 223389b9..7bc8e7d0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -50,7 +50,7 @@ shortcuts List available shortcuts
"""
# Help text for the history command
-HELP_HISTORY = """Usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT | -c] [arg]
+HELP_HISTORY = """Usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT | -v | -c] [arg]
View, run, edit, save, or clear previously entered commands
@@ -70,6 +70,7 @@ optional arguments:
output commands to a script file
-t, --transcript TRANSCRIPT
output commands and results to a transcript file
+ -v, --verbose display history and include expanded commands if they differ from the typed command.
-c, --clear clear all history
"""
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index b10322f1..576bdc0c 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -304,8 +304,12 @@ def test_base_error(base_app):
@pytest.fixture
def hist():
+ from cmd2.parsing import Statement
from cmd2.cmd2 import History, HistoryItem
- h = History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')])
+ h = History([HistoryItem(Statement('', raw='first')),
+ HistoryItem(Statement('', raw='second')),
+ HistoryItem(Statement('', raw='third')),
+ HistoryItem(Statement('', raw='fourth'))])
return h
def test_history_span(hist):
@@ -335,24 +339,20 @@ def test_base_history(base_app):
run_cmd(base_app, 'shortcuts')
out = run_cmd(base_app, 'history')
expected = normalize("""
--------------------------[1]
-help
--------------------------[2]
-shortcuts
+ 1 help
+ 2 shortcuts
""")
assert out == expected
out = run_cmd(base_app, 'history he')
expected = normalize("""
--------------------------[1]
-help
+ 1 help
""")
assert out == expected
out = run_cmd(base_app, 'history sh')
expected = normalize("""
--------------------------[2]
-shortcuts
+ 2 shortcuts
""")
assert out == expected
@@ -372,10 +372,8 @@ def test_history_with_string_argument(base_app):
run_cmd(base_app, 'help history')
out = run_cmd(base_app, 'history help')
expected = normalize("""
--------------------------[1]
-help
--------------------------[3]
-help history
+ 1 help
+ 3 help history
""")
assert out == expected
@@ -385,8 +383,7 @@ def test_history_with_integer_argument(base_app):
run_cmd(base_app, 'shortcuts')
out = run_cmd(base_app, 'history 1')
expected = normalize("""
--------------------------[1]
-help
+ 1 help
""")
assert out == expected
@@ -397,10 +394,8 @@ def test_history_with_integer_span(base_app):
run_cmd(base_app, 'help history')
out = run_cmd(base_app, 'history 1..2')
expected = normalize("""
--------------------------[1]
-help
--------------------------[2]
-shortcuts
+ 1 help
+ 2 shortcuts
""")
assert out == expected
@@ -410,10 +405,8 @@ def test_history_with_span_start(base_app):
run_cmd(base_app, 'help history')
out = run_cmd(base_app, 'history 2:')
expected = normalize("""
--------------------------[2]
-shortcuts
--------------------------[3]
-help history
+ 2 shortcuts
+ 3 help history
""")
assert out == expected
@@ -423,10 +416,8 @@ def test_history_with_span_end(base_app):
run_cmd(base_app, 'help history')
out = run_cmd(base_app, 'history :2')
expected = normalize("""
--------------------------[1]
-help
--------------------------[2]
-shortcuts
+ 1 help
+ 2 shortcuts
""")
assert out == expected
@@ -436,8 +427,7 @@ def test_history_with_span_index_error(base_app):
run_cmd(base_app, '!ls -hal :')
out = run_cmd(base_app, 'history "hal :"')
expected = normalize("""
--------------------------[3]
-!ls -hal :
+ 3 !ls -hal :
""")
assert out == expected
@@ -957,8 +947,7 @@ def test_exclude_from_history(base_app, monkeypatch):
run_cmd(base_app, 'help')
# And verify we have a history now ...
out = run_cmd(base_app, 'history')
- expected = normalize("""-------------------------[1]
-help""")
+ expected = normalize(""" 1 help""")
assert out == expected
diff --git a/tests/transcripts/from_cmdloop.txt b/tests/transcripts/from_cmdloop.txt
index 8c0dd007..871b71f1 100644
--- a/tests/transcripts/from_cmdloop.txt
+++ b/tests/transcripts/from_cmdloop.txt
@@ -35,18 +35,12 @@ OODNIGHT, GRACIEGAY
OODNIGHT, GRACIEGAY
OODNIGHT, GRACIEGAY
(Cmd) history
--------------------------[1]
-help
--------------------------[2]
-help say
--------------------------[3]
-say goodnight, Gracie
--------------------------[4]
-say -ps --repeat=5 goodnight, Gracie
--------------------------[5]
-set maxrepeats 5
--------------------------[6]
-say -ps --repeat=5 goodnight, Gracie
+ 1 help
+ 2 help say
+ 3 say goodnight, Gracie
+ 4 say -ps --repeat=5 goodnight, Gracie
+ 5 set maxrepeats 5
+ 6 say -ps --repeat=5 goodnight, Gracie
(Cmd) history -r 4
say -ps --repeat=5 goodnight, Gracie
OODNIGHT, GRACIEGAY