MCPcopy
hub / github.com/pallets/flask / test_appgroup_app_context

Function test_appgroup_app_context

tests/test_cli.py:320–345  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

318
319
320def test_appgroup_app_context(runner):
321 @click.group(cls=AppGroup)
322 def cli():
323 pass
324
325 @cli.command()
326 def test():
327 click.echo(current_app.name)
328
329 @cli.group()
330 def subgroup():
331 pass
332
333 @subgroup.command()
334 def test2():
335 click.echo(current_app.name)
336
337 obj = ScriptInfo(create_app=lambda: Flask("testappgroup"))
338
339 result = runner.invoke(cli, ["test"], obj=obj)
340 assert result.exit_code == 0
341 assert result.output == "testappgroup\n"
342
343 result = runner.invoke(cli, ["subgroup", "test2"], obj=obj)
344 assert result.exit_code == 0
345 assert result.output == "testappgroup\n"
346
347
348def test_flaskgroup_app_context(runner):

Callers

nothing calls this directly

Calls 3

ScriptInfoClass · 0.90
FlaskClass · 0.90
invokeMethod · 0.45

Tested by

no test coverage detected