forked from orbit-oss/flask
Add option to not overwrite debug flag in cli
This is mainly intended for custom CLIs that may load a config file which already sets the debug flag and does not make use of the `FLASK_*` env vars at all.
This commit is contained in:
parent
b34c7174e7
commit
50227f0954
3 changed files with 39 additions and 9 deletions
|
|
@ -356,6 +356,28 @@ def test_flaskgroup(runner):
|
|||
assert result.output == 'flaskgroup\n'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('set_debug_flag', (True, False))
|
||||
def test_flaskgroup_debug(runner, set_debug_flag):
|
||||
"""Test FlaskGroup debug flag behavior."""
|
||||
|
||||
def create_app(info):
|
||||
app = Flask("flaskgroup")
|
||||
app.debug = True
|
||||
return app
|
||||
|
||||
@click.group(cls=FlaskGroup, create_app=create_app, set_debug_flag=set_debug_flag)
|
||||
def cli(**params):
|
||||
pass
|
||||
|
||||
@cli.command()
|
||||
def test():
|
||||
click.echo(str(current_app.debug))
|
||||
|
||||
result = runner.invoke(cli, ['test'])
|
||||
assert result.exit_code == 0
|
||||
assert result.output == '%s\n' % str(not set_debug_flag)
|
||||
|
||||
|
||||
def test_print_exceptions(runner):
|
||||
"""Print the stacktrace if the CLI."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue