Error : E RuntimeError: Task <Task pending name='Task-3' coro=<test_index() running at /home/chintal/Desktop/yt-stories/fastapi-boilerplate/src/test/user/test_controller.py:41> cb=[_run_until_complete_cb() at /usr/lib/python3.8/asyncio/base_events.py:184, WorkerThread.stop()]> got Future attached to a different loop asyncpg/protocol/protocol.pyx:338: RuntimeError
import pytest
from httpx import AsyncClient
from app.server import app
"""Use below code to test async functions"""
@pytest.mark.asyncio
async def test_index_one():
async with AsyncClient(app=app, base_url="http://test") as ac:
response = await ac.get("/v1/user/test/user/2")
assert response.status_code == 200
@pytest.mark.asyncio
async def test_index():
async with AsyncClient(app=app, base_url="http://test") as ac:
response = await ac.get("/v1/user/test/user/1")
assert response.status_code == 200