import os import pytest from fastapi.testclient import TestClient from psycopg_pool import AsyncConnectionPool from src.neo_neo_todo.main import app @pytest.fixture async def client(): yield TestClient(app) @pytest.fixture async def db_pool(): try: postgres_db_url = os.environ["TODO_DB_DATABASE_URL"] except KeyError: raise KeyError("Can't find postgres DB URL") pool = AsyncConnectionPool(postgres_db_url, open=False) await pool.open() yield pool await pool.close()