diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-04-15 19:18:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 19:18:49 -0400 |
commit | ba42eb40199652224601b118b7411c59d4a14340 (patch) | |
tree | 24b34d3300e96d0b39493d5d4e554fa2fdc1da46 /tests/test_cmd2.py | |
parent | c5aa3fd31567574a9ed9fa97f7ba7e7083af707f (diff) | |
parent | 85bb29b7edfc6485556f398ddb192c16d1509856 (diff) | |
download | cmd2-git-ba42eb40199652224601b118b7411c59d4a14340.tar.gz |
Merge branch 'master' into table_creator
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-x | tests/test_cmd2.py | 34 |
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): |