def gen_with_app(*args, **kwargs):
 def generator(func):
  @wraps(func)
  def deco(*args2, **kwargs2):
   app = TestApp(*args, **kwargs)
   for item in func(app, *args2, **kwargs2):
    (yield item)
   app.cleanup()
  return deco
 return generator

def gen_with_app ( * args , ** kwargs ) : def generator ( func ) : @ wraps ( func ) def deco ( * args2 , ** kwargs2 ) : app = TestApp ( * args , ** kwargs ) for item in func ( app , * args2 , ** kwargs2 ) : ( yield item ) app . cleanup ( ) return deco return generator
decorate a test generator to pass a testapp as the first argument to the test generator when its executed .