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.py18
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]