From 03b91a3adc3421f662b79c876992225f8440d38e Mon Sep 17 00:00:00 2001 From: John Aziz Date: Fri, 26 Apr 2024 23:45:14 +0300 Subject: [PATCH 1/2] fix async_generator error by passing the fixture name as an argument We are yielding the app fixture but not passing it as an argument which seems to break the second part of the documentation where we attempt to access the `test_client()` it gives an async_generator. ```bash AttributeError: 'async_generator' object has no attribute 'test_client' ``` --- docs/how_to_guides/startup_shutdown.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how_to_guides/startup_shutdown.rst b/docs/how_to_guides/startup_shutdown.rst index c1ca1bf..40280d7 100644 --- a/docs/how_to_guides/startup_shutdown.rst +++ b/docs/how_to_guides/startup_shutdown.rst @@ -65,7 +65,7 @@ for example .. code-block:: python @pytest.fixture(name="app", scope="function") - async def _app(): + async def _app(app): app = create_app() # Initialize app async with app.test_app() as test_app: yield test_app From 0230b82c167866a071f4f6298d74cb5990c677de Mon Sep 17 00:00:00 2001 From: John Aziz Date: Sat, 27 Apr 2024 00:14:37 +0300 Subject: [PATCH 2/2] Update startup_shutdown.rst --- docs/how_to_guides/startup_shutdown.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/how_to_guides/startup_shutdown.rst b/docs/how_to_guides/startup_shutdown.rst index 40280d7..a45a84f 100644 --- a/docs/how_to_guides/startup_shutdown.rst +++ b/docs/how_to_guides/startup_shutdown.rst @@ -64,8 +64,8 @@ for example .. code-block:: python - @pytest.fixture(name="app", scope="function") - async def _app(app): + @pytest_asyncio.fixture(name="app", scope="function") + async def _app(): app = create_app() # Initialize app async with app.test_app() as test_app: yield test_app