diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/redirect.txt | 1 | ||||
| -rw-r--r-- | tests/test_cmd2.py | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/tests/redirect.txt b/tests/redirect.txt new file mode 100644 index 00000000..c375d5ba --- /dev/null +++ b/tests/redirect.txt @@ -0,0 +1 @@ +history diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index d352bd4e..a27c5f2b 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -463,7 +463,7 @@ def test_base_py_interactive(base_app): m.assert_called_once() -def test_base_cmdloop_with_queue(capsys): +def test_base_cmdloop_with_queue(): # Create a cmd2.Cmd() instance and make sure basic settings are like we want for test app = cmd2.Cmd() app.use_rawinput = True @@ -479,3 +479,15 @@ def test_base_cmdloop_with_queue(capsys): app.cmdloop() out = app.stdout.buffer assert out == expected + + +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 from a file works + out = run_cmd(base_app, 'help < {}'.format(filename)) + expected = normalize(HELP_HISTORY) + assert out == expected |
