From ed17bc171046a15f03c890687db8eb9652513bd9 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Thu, 16 Mar 2017 20:56:12 +0100 Subject: [PATCH] Add test to showcase that printing a traceback works --- tests/test_cli.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 313a34d2..82c69f93 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -191,3 +191,20 @@ def test_flaskgroup(): result = runner.invoke(cli, ['test']) assert result.exit_code == 0 assert result.output == 'flaskgroup\n' + + +def test_print_exceptions(): + """Print the stacktrace if the CLI.""" + def create_app(info): + raise Exception("oh no") + return Flask("flaskgroup") + + @click.group(cls=FlaskGroup, create_app=create_app) + def cli(**params): + pass + + runner = CliRunner() + result = runner.invoke(cli, ['--help']) + assert result.exit_code == 0 + assert 'Exception: oh no' in result.output + assert 'Traceback' in result.output