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

Function test_app_cli_has_app_context

tests/test_cli.py:289–304  ·  view source on GitHub ↗
(app, runner)

Source from the content-addressed store, hash-verified

287
288
289def test_app_cli_has_app_context(app, runner):
290 def _param_cb(ctx, param, value):
291 # current_app should be available in parameter callbacks
292 return bool(current_app)
293
294 @app.cli.command()
295 @click.argument("value", callback=_param_cb)
296 def check(value):
297 app = click.get_current_context().obj.load_app()
298 # the loaded app should be the same as current_app
299 same_app = current_app._get_current_object() is app
300 return same_app, value
301
302 cli = FlaskGroup(create_app=lambda: app)
303 result = runner.invoke(cli, ["check", "x"], standalone_mode=False)
304 assert result.return_value == (True, True)
305
306
307def test_with_appcontext(runner):

Callers

nothing calls this directly

Calls 2

FlaskGroupClass · 0.90
invokeMethod · 0.45

Tested by

no test coverage detected