Skip to content

FastAPI

FastAPI入門2

昨日の続き。テストを流した時のエラーは、参考にしたサイトのものと一部バージョンが変わっているのが原因らしく。 pytest-asyncio のモードのデフォルト値が変わったよ&出戻りのご連絡|基幹システムのクラウド移行・構築・導入支援のBeeX を参考に@pytest.fixtureを@pytest_asyncio.fixture Read more

FastAPI入門

FastAPI入門をやってみた。 特にひっかかることなく進めたが、最後のテストがPASSしない。 $ docker-compose run --entrypoint "poetry run pytest" demo-app [+] Building 0.0s (0/0) docker:default [+] Building 0.0s (0/0) docker:default ======================================================= test session starts ========================================================platform linux -- Python 3.9.17, pytest-7.4.2, pluggy-1.3.0 rootdir: /src plugins: anyio-3.7.1, asyncio-0.21.1 asyncio: mode=strict collected 2 items tests/test_main.py FF [100%] ============================================================= FAILURES ============================================================= _______________________________________________________ test_create_and_read _______________________________________________________ async_client = <async_generator object async_client at 0x7f8d3374dca0> @pytest.mark.asyncio async def test_create_and_read(async_client): > response = await async_client.post("/tasks", json={"title": "テストタスク"}) E AttributeError: 'async_generator' object has no attribute 'post' tests/test_main.py:41: AttributeError __________________________________________________________ test_done_flag __________________________________________________________ async_client = <async_generator object async_client at 0x7f8d3374ddc0> Read more