def test_appgroup():
 @click.group(cls=AppGroup)
 def cli():
  pass
 @cli.command(with_appcontext=True)
 def test():
  click.echo(current_app.name)
 @cli.group()
 def subgroup():
  pass
 @subgroup.command(with_appcontext=True)
 def test2():
  click.echo(current_app.name)
 obj = ScriptInfo(create_app=(lambda info: Flask('testappgroup')))
 runner = CliRunner()
 result = runner.invoke(cli, ['test'], obj=obj)
 assert (result.exit_code == 0)
 assert (result.output == 'testappgroup\n')
 result = runner.invoke(cli, ['subgroup', 'test2'], obj=obj)
 assert (result.exit_code == 0)
 assert (result.output == 'testappgroup\n')

def test_appgroup ( ) : @ click . group ( cls = AppGroup ) def cli ( ) : pass @ cli . command ( with_appcontext = True ) def test ( ) : click . echo ( current_app . name ) @ cli . group ( ) def subgroup ( ) : pass @ subgroup . command ( with_appcontext = True ) def test2 ( ) : click . echo ( current_app . name ) obj = ScriptInfo ( create_app = ( lambda info : Flask ( 'testappgroup' ) ) ) runner = CliRunner ( ) result = runner . invoke ( cli , [ 'test' ] , obj = obj ) assert ( result . exit_code == 0 ) assert ( result . output == 'testappgroup\n' ) result = runner . invoke ( cli , [ 'subgroup' , 'test2' ] , obj = obj ) assert ( result . exit_code == 0 ) assert ( result . output == 'testappgroup\n' )
test of with_appcontext .