diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-13 23:59:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 23:59:03 -0400 |
commit | 3ee97d121887d3055fc6326b1d9bc290f5235866 (patch) | |
tree | f5695aece2c4e6173513da3f436df73099b88c09 /tests/test_cmd2.py | |
parent | cbf0313306c99c02f3c503f60d70df4bda2cce64 (diff) | |
parent | 6c051808d83b75108c0549acbc97fe2201f8de63 (diff) | |
download | cmd2-git-3ee97d121887d3055fc6326b1d9bc290f5235866.tar.gz |
Merge pull request #676 from python-cmd2/pipe_chaining
Pipe chaining
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r-- | tests/test_cmd2.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 5f6af8c5..7a17cfac 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -576,11 +576,26 @@ def test_pipe_to_shell(base_app): out, err = run_cmd(base_app, command) assert out and not err +def test_pipe_to_shell_and_redirect(base_app): + filename = 'out.txt' + if sys.platform == "win32": + # Windows + command = 'help | sort > {}'.format(filename) + else: + # Mac and Linux + # Get help on help and pipe it's output to the input of the word count shell command + command = 'help help | wc > {}'.format(filename) + + out, err = run_cmd(base_app, command) + assert not out and not err + assert os.path.exists(filename) + os.remove(filename) + def test_pipe_to_shell_error(base_app): # Try to pipe command output to a shell command that doesn't exist in order to produce an error out, err = run_cmd(base_app, 'help | foobarbaz.this_does_not_exist') assert not out - assert "Failed to open pipe because" in err[0] + assert "Pipe process exited with code" in err[0] @pytest.mark.skipif(not clipboard.can_clip, reason="Pyperclip could not find a copy/paste mechanism for your system") @@ -1713,7 +1728,6 @@ def test_macro_create_with_alias_name(base_app): assert "Macro cannot have the same name as an alias" in err[0] def test_macro_create_with_command_name(base_app): - macro = "my_macro" out, err = run_cmd(base_app, 'macro create help stuff') assert "Macro cannot have the same name as a command" in err[0] |