diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 14:54:04 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-05 14:54:04 -0500 |
| commit | 7a6ee406bdcdb84a410b2e623657d71ea84d4625 (patch) | |
| tree | 57eeefa65851556626bbf5837c10fa6443ce7f0e | |
| parent | 307f9431526dfa05d1d352cd5feb04f5fc6dad9c (diff) | |
| download | cmd2-git-7a6ee406bdcdb84a410b2e623657d71ea84d4625.tar.gz | |
Added unit test for redirecting input from a file using <
| -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 |
