summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-22 21:07:06 -0500
committerGitHub <noreply@github.com>2018-01-22 21:07:06 -0500
commitddfd3d9a400ae81468e9abcc89fe690c30b7ec7f (patch)
tree720e9b58b694dff8f8c2513918e16a11ea24321f /tests/test_cmd2.py
parent7b564b4424accfbd7439de10a169d9b64bc599c5 (diff)
parent504e3dbf9e15faf34611aae8ddabecb90e86eda5 (diff)
downloadcmd2-git-ddfd3d9a400ae81468e9abcc89fe690c30b7ec7f.tar.gz
Merge pull request #257 from python-cmd2/sub-commands
Sub-commands and automatic transcript generation
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 30308dd7..186def65 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -25,7 +25,7 @@ from conftest import run_cmd, normalize, BASE_HELP, HELP_HISTORY, SHORTCUTS_TXT,
def test_ver():
- assert cmd2.__version__ == '0.8.0a'
+ assert cmd2.__version__ == '0.8.0'
def test_empty_statement(base_app):
@@ -41,19 +41,24 @@ def test_base_help(base_app):
def test_base_help_history(base_app):
out = run_cmd(base_app, 'help history')
- expected = normalize(HELP_HISTORY)
- assert out == expected
+ assert out == normalize(HELP_HISTORY)
def test_base_argparse_help(base_app, capsys):
+ # Verify that "set -h" gives the same output as "help set" and that it starts in a way that makes sense
run_cmd(base_app, 'set -h')
out, err = capsys.readouterr()
- expected = run_cmd(base_app, 'help set')
- assert normalize(base_app.do_set.__doc__ + str(err)) == expected
+ out1 = out.splitlines()
+
+ out2 = run_cmd(base_app, 'help set')
+
+ assert out1 == out2
+ assert out1[0].startswith('usage: set')
+ assert out1[1] == ''
+ assert out1[2].startswith('Sets a settable parameter')
def test_base_invalid_option(base_app, capsys):
run_cmd(base_app, 'set -z')
out, err = capsys.readouterr()
- run_cmd(base_app, 'help set')
expected = ['usage: set [-h] [-a] [-l] [settable [settable ...]]', 'set: error: unrecognized arguments: -z']
assert normalize(str(err)) == expected
@@ -605,8 +610,7 @@ def test_input_redirection(base_app, request):
# Verify that redirecting input ffom a file works
out = run_cmd(base_app, 'help < {}'.format(filename))
- expected = normalize(HELP_HISTORY)
- assert out == expected
+ assert out == normalize(HELP_HISTORY)
def test_pipe_to_shell(base_app, capsys):