summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_cmd2.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index bb99e15b..fe3f25a6 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -480,20 +480,11 @@ def test_output_redirection(base_app):
def test_output_redirection_to_nonexistent_directory(base_app):
filename = '~/fakedir/this_does_not_exist.txt'
- # Verify that writing to a file in a non-existent directory doesn't work
- run_cmd(base_app, 'help > {}'.format(filename))
- with pytest.raises(FileNotFoundError):
- with open(filename) as f:
- content = f.read()
- verify_help_text(base_app, content)
+ out, err = run_cmd(base_app, 'help > {}'.format(filename))
+ assert 'Failed to redirect' in err[0]
- # Verify that appending to a file also works
- run_cmd(base_app, 'help history >> {}'.format(filename))
- with pytest.raises(FileNotFoundError):
- with open(filename) as f:
- appended_content = f.read()
- verify_help_text(base_app, appended_content)
- assert len(appended_content) > len(content)
+ out, err = run_cmd(base_app, 'help >> {}'.format(filename))
+ assert 'Failed to redirect' in err[0]
def test_output_redirection_to_too_long_filename(base_app):
filename = '~/sdkfhksdjfhkjdshfkjsdhfkjsdhfkjdshfkjdshfkjshdfkhdsfkjhewfuihewiufhweiufhiweufhiuewhiuewhfiuwehfia' \
@@ -502,20 +493,11 @@ def test_output_redirection_to_too_long_filename(base_app):
'fheiufhieuwhfewiuhfeiufhiuewfhiuewheiwuhfiuewhfiuewhfeiuwfhewiufhiuewhiuewhfeiuwhfiuwehfuiwehfiuehie' \
'whfieuwfhieufhiuewhfeiuwfhiuefhueiwhfw'
- # Verify that writing to a file in a non-existent directory doesn't work
- run_cmd(base_app, 'help > {}'.format(filename))
- with pytest.raises(OSError):
- with open(filename) as f:
- content = f.read()
- verify_help_text(base_app, content)
+ out, err = run_cmd(base_app, 'help > {}'.format(filename))
+ assert 'Failed to redirect' in err[0]
- # Verify that appending to a file also works
- run_cmd(base_app, 'help history >> {}'.format(filename))
- with pytest.raises(OSError):
- with open(filename) as f:
- appended_content = f.read()
- verify_help_text(base_app, content)
- assert len(appended_content) > len(content)
+ out, err = run_cmd(base_app, 'help >> {}'.format(filename))
+ assert 'Failed to redirect' in err[0]
def test_feedback_to_output_true(base_app):