diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-24 12:55:06 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-24 12:55:06 -0400 |
commit | c3fe0573e2877c76adc6209453a92ef82ff6b6f2 (patch) | |
tree | 89c586a412b776c4dee7cecf4c5ddcdcc5bcb747 /tests | |
parent | d333a992292ddeb40d24d82a6bef0d4ed35db37a (diff) | |
download | cmd2-git-c3fe0573e2877c76adc6209453a92ef82ff6b6f2.tar.gz |
Removed most return statements from finally blocks to avoid hiding exceptions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 76470145..4fc9fd59 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -786,12 +786,11 @@ def test_cmdloop_without_rawinput(outsim_app): testargs = ["prog"] expected = outsim_app.intro + '\n' with mock.patch.object(sys, 'argv', testargs): - # Run the command loop - outsim_app.cmdloop() + with pytest.raises(OSError): + outsim_app.cmdloop() out = outsim_app.stdout.getvalue() assert out == expected - class HookFailureApp(cmd2.Cmd): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -840,7 +839,10 @@ def test_interrupt_quit(say_app): m.side_effect = ['say hello', KeyboardInterrupt(), 'say goodbye', 'eof'] builtins.input = m - say_app.cmdloop() + try: + say_app.cmdloop() + except KeyboardInterrupt: + pass # And verify the expected output to stdout out = say_app.stdout.getvalue() @@ -854,7 +856,10 @@ def test_interrupt_noquit(say_app): m.side_effect = ['say hello', KeyboardInterrupt(), 'say goodbye', 'eof'] builtins.input = m - say_app.cmdloop() + try: + say_app.cmdloop() + except KeyboardInterrupt: + pass # And verify the expected output to stdout out = say_app.stdout.getvalue() |