diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-05-25 17:49:20 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-05-25 17:49:20 -0400 |
commit | 1fe024f33574af02c93d4df0eb0ddb88e690305a (patch) | |
tree | f7a86354c3f94ea1c3549974c48b7e0ab9d01aa9 /tests | |
parent | 2c96da06b2009760bebc20bec1980bf34df93d86 (diff) | |
download | cmd2-git-1fe024f33574af02c93d4df0eb0ddb88e690305a.tar.gz |
Refactored implementation of HistoryItem.__str__ and added an explicit HistoryItem unit test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_history.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/test_history.py b/tests/test_history.py index 3a52bda9..11133456 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -5,8 +5,6 @@ Test history functions of cmd2 """ import tempfile import os -import pickle -import sys import pytest @@ -18,6 +16,8 @@ except ImportError: import cmd2 from .conftest import run_cmd, normalize, HELP_HISTORY +from cmd2.parsing import Statement +from cmd2.history import HistoryItem def test_base_help_history(base_app): @@ -50,17 +50,26 @@ def test_exclude_from_history(base_app, monkeypatch): expected = normalize(""" 1 help""") assert out == expected - @pytest.fixture def hist(): - from cmd2.parsing import Statement - from cmd2.cmd2 import History, HistoryItem + from cmd2.history import History h = History([HistoryItem(Statement('', raw='first'), 1), HistoryItem(Statement('', raw='second'), 2), HistoryItem(Statement('', raw='third'), 3), - HistoryItem(Statement('', raw='fourth'),4)]) + HistoryItem(Statement('', raw='fourth'), 4)]) return h +def test_history_item(): + raw = 'help' + stmt = Statement('', raw=raw) + index = 1 + hi = HistoryItem(stmt, index) + assert hi.statement == stmt + assert hi.idx == index + assert hi.statement.raw == raw + assert str(hi) == raw + + def test_history_class_span(hist): for tryit in ['*', ':', '-', 'all', 'ALL']: assert hist.span(tryit) == hist |