Support calling with_appcontext decorator with parenthesis

Calling without parenthesis still works the same. Just to have a bit more parity with Quart.
This commit is contained in:
Filip Š 2022-07-16 16:47:43 +02:00
parent 900e11850a
commit 8d62f5e8c6
3 changed files with 23 additions and 2 deletions

View file

@ -341,6 +341,19 @@ def test_with_appcontext(runner):
assert result.output == "testapp\n"
def test_with_appcontext_parenthesis(runner):
@click.command()
@with_appcontext()
def testcmd():
click.echo(current_app.name)
obj = ScriptInfo(create_app=lambda: Flask("testapp"))
result = runner.invoke(testcmd, obj=obj)
assert result.exit_code == 0
assert result.output == "testapp\n"
def test_appgroup_app_context(runner):
@click.group(cls=AppGroup)
def cli():