diff --git a/examples/miniapps/fastapi/README.rst b/examples/miniapps/fastapi/README.rst index 3191465f..779ccac8 100644 --- a/examples/miniapps/fastapi/README.rst +++ b/examples/miniapps/fastapi/README.rst @@ -101,21 +101,21 @@ The output should be something like: .. code-block:: - platform darwin -- Python 3.9, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 - plugins: cov-2.10.0, asyncio-0.14.0 + platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 + plugins: asyncio-0.16.0, cov-3.0.0 collected 3 items giphynavigator/tests.py ... [100%] - ---------- coverage: platform darwin, python 3.9 ----------- + ---------- coverage: platform darwin, python 3.10.0-final-0 ---------- Name Stmts Miss Cover --------------------------------------------------- giphynavigator/__init__.py 0 0 100% - giphynavigator/application.py 13 0 100% - giphynavigator/containers.py 6 0 100% + giphynavigator/application.py 11 0 100% + giphynavigator/containers.py 7 0 100% giphynavigator/endpoints.py 20 0 100% giphynavigator/giphy.py 14 9 36% giphynavigator/services.py 9 1 89% - giphynavigator/tests.py 38 0 100% + giphynavigator/tests.py 37 0 100% --------------------------------------------------- - TOTAL 100 10 90% + TOTAL 98 10 90% diff --git a/examples/miniapps/fastapi/giphynavigator/application.py b/examples/miniapps/fastapi/giphynavigator/application.py index 28883eaa..4cb0af2e 100644 --- a/examples/miniapps/fastapi/giphynavigator/application.py +++ b/examples/miniapps/fastapi/giphynavigator/application.py @@ -8,9 +8,7 @@ from . import endpoints def create_app() -> FastAPI: container = Container() - container.config.from_yaml("config.yml") container.config.giphy.api_key.from_env("GIPHY_API_KEY") - container.wire(modules=[endpoints]) app = FastAPI() app.container = container diff --git a/examples/miniapps/fastapi/giphynavigator/containers.py b/examples/miniapps/fastapi/giphynavigator/containers.py index 730c162e..15777679 100644 --- a/examples/miniapps/fastapi/giphynavigator/containers.py +++ b/examples/miniapps/fastapi/giphynavigator/containers.py @@ -7,7 +7,9 @@ from . import giphy, services class Container(containers.DeclarativeContainer): - config = providers.Configuration() + wiring_config = containers.WiringConfiguration(modules=[".endpoints"]) + + config = providers.Configuration(yaml_files=["config.yml"]) giphy_client = providers.Factory( giphy.GiphyClient, diff --git a/examples/miniapps/fastapi/giphynavigator/tests.py b/examples/miniapps/fastapi/giphynavigator/tests.py index 18116971..2b57d50d 100644 --- a/examples/miniapps/fastapi/giphynavigator/tests.py +++ b/examples/miniapps/fastapi/giphynavigator/tests.py @@ -10,10 +10,9 @@ from giphynavigator.giphy import GiphyClient @pytest.fixture -def client(event_loop): - client = AsyncClient(app=app, base_url="http://test") - yield client - event_loop.run_until_complete(client.aclose()) +async def client(): + async with AsyncClient(app=app, base_url="http://test") as client: + yield client @pytest.mark.asyncio