summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 9fb9f2d9..186def65 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -39,26 +39,22 @@ def test_base_help(base_app):
assert out == expected
-def test_base_help_history(base_app, capsys):
- run_cmd(base_app, 'help history')
- out, err = capsys.readouterr()
- assert out == HELP_HISTORY
- assert err == ''
+def test_base_help_history(base_app):
+ out = run_cmd(base_app, 'help history')
+ 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')
- out1, err1 = capsys.readouterr()
+ out, err = capsys.readouterr()
+ out1 = out.splitlines()
- run_cmd(base_app, 'help set')
- out2, err2 = capsys.readouterr()
+ out2 = run_cmd(base_app, 'help set')
assert out1 == out2
- assert err1 == err2
- out = out1.splitlines()
- assert out[0].startswith('usage: set')
- assert out[1] == ''
- assert out[2].startswith('Sets a settable parameter')
+ 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')
@@ -606,17 +602,15 @@ def test_allow_redirection(base_app):
assert not os.path.exists(filename)
-def test_input_redirection(base_app, request, capsys):
+def test_input_redirection(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'redirect.txt')
# NOTE: File 'redirect.txt" contains 1 word "history"
# Verify that redirecting input ffom a file works
- run_cmd(base_app, 'help < {}'.format(filename))
- out, err = capsys.readouterr()
- assert out == HELP_HISTORY
- assert err == ''
+ out = run_cmd(base_app, 'help < {}'.format(filename))
+ assert out == normalize(HELP_HISTORY)
def test_pipe_to_shell(base_app, capsys):