async def test_test_app() -> None: startup = False shutdown = False app = Quart(__name__) @app.before_serving async def before() -> None: nonlocal startup startup = True @app.after_serving async def after() -> None: nonlocal shutdown shutdown = True @app.route("/") async def index() -> str: return "" async with app.test_app() as test_app: assert startup test_client = test_app.test_client() await test_client.get("/") assert not shutdown assert shutdown
async def test_test_app() -> None: startup = False shutdown = False serving = [] app = Quart(__name__) @app.before_serving async def before() -> None: nonlocal startup startup = True @app.after_serving async def after() -> None: nonlocal shutdown shutdown = True @app.while_serving async def lifespan() -> AsyncGenerator[None, None]: nonlocal serving serving.append(1) yield serving.append(2) @app.route("/") async def index() -> str: return "" async with app.test_app() as test_app: assert startup test_client = test_app.test_client() await test_client.get("/") assert not shutdown assert serving == [1] assert shutdown assert serving == [1, 2]