summaryrefslogtreecommitdiff
path: root/tests/test_parsing.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-02 15:06:25 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-02 15:06:25 -0400
commitf4c3013a7215e45d6200f14f6c8164a10693aacd (patch)
tree5cdc86bc6d78e98b1fee2c1090fed47a6dddde53 /tests/test_parsing.py
parent02f234fc6af3e5c2d1434f1a8d52f808ff795dd4 (diff)
downloadcmd2-git-f4c3013a7215e45d6200f14f6c8164a10693aacd.tar.gz
Added a bunch of unit tests
Also improved error handling in some exceptional cases.
Diffstat (limited to 'tests/test_parsing.py')
-rw-r--r--tests/test_parsing.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index dda29911..1a32a734 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -20,7 +20,6 @@ def hist():
h = cmd2.History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')])
return h
-
@pytest.fixture
def parser():
c = cmd2.Cmd()
@@ -38,6 +37,11 @@ def input_parser():
c = cmd2.Cmd()
return c.parser_manager.input_source_parser
+@pytest.fixture
+def option_parser():
+ op = cmd2.OptionParser()
+ return op
+
def test_remaining_args():
assert cmd2.remaining_args('-f bar bar cow', ['bar', 'cow']) == 'bar cow'
@@ -265,3 +269,11 @@ def test_parse_input_redirect_from_unicode_filename(input_parser):
line = '< café'
results = input_parser.parseString(line)
assert results.inputFrom == line
+
+
+def test_option_parser_exit_with_msg(option_parser, capsys):
+ msg = 'foo bar'
+ option_parser.exit(msg=msg)
+ out, err = capsys.readouterr()
+ assert out == msg + '\n'
+ assert err == ''