Skip to content

Commit 1ecaddf

Browse files
committed
Added unit test
1 parent 9458307 commit 1ecaddf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_cmd2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,21 @@ def test_pipe_to_shell(base_app):
576576
out, err = run_cmd(base_app, command)
577577
assert out and not err
578578

579+
def test_pipe_to_shell_and_redirect(base_app):
580+
filename = 'out.txt'
581+
if sys.platform == "win32":
582+
# Windows
583+
command = 'help | sort > {}'.format(filename)
584+
else:
585+
# Mac and Linux
586+
# Get help on help and pipe it's output to the input of the word count shell command
587+
command = 'help help | wc > {}'.format(filename)
588+
589+
out, err = run_cmd(base_app, command)
590+
assert not out and not err
591+
assert os.path.exists(filename)
592+
os.remove(filename)
593+
579594
def test_pipe_to_shell_error(base_app):
580595
# Try to pipe command output to a shell command that doesn't exist in order to produce an error
581596
out, err = run_cmd(base_app, 'help | foobarbaz.this_does_not_exist')

0 commit comments

Comments
 (0)