diff --git a/sceptre/cli/helpers.py b/sceptre/cli/helpers.py index 69edba63f..ffce230f3 100644 --- a/sceptre/cli/helpers.py +++ b/sceptre/cli/helpers.py @@ -1,5 +1,4 @@ import logging -import sys from functools import partial, wraps import json @@ -30,14 +29,14 @@ def catch_exceptions(func): def decorated(*args, **kwargs): """ Invokes ``func``, catches expected errors, prints the error message and - exits sceptre with a non-zero exit code. + re-raises. """ try: return func(*args, **kwargs) except (SceptreException, BotoCoreError, ClientError, Boto3Error, TemplateError) as error: write(error) - sys.exit(1) + raise return decorated diff --git a/tests/test_cli.py b/tests/test_cli.py index d13d43716..74a5f9bc3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -55,14 +55,13 @@ def teardown_method(self, test_method): self.patcher_ConfigReader.stop() self.patcher_StackActions.stop() - @patch("sys.exit") - def test_catch_excecptions(self, mock_exit): + def test_catch_excecptions(self): @catch_exceptions def raises_exception(): raise SceptreException() - raises_exception() - mock_exit.assert_called_once_with(1) + with pytest.raises(SceptreException): + raises_exception() @pytest.mark.parametrize("command,files,output", [ # one --var option