You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to `fastapi` version change, the newer `TestClient` from
`fastapi` is causing issues by creating its own different event
loop (Reference: https://www.starlette.io/testclient/).
That conflicts with the event loop of database client created in
the app startup handler.
Fix the below error by using async test client for all the tests:
```
@pytest.fixture(scope='session')
def test_client():
"""Fixture to get FastAPI Test client instance"""
with TestClient(app=versioned_app, base_url=BASE_URL) as client:
tests/e2e_tests/conftest.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
api/main.py:87: in initialize_beanie
await db.initialize_beanie()
api/db.py:51: in initialize_beanie
await init_beanie(
.local/lib/python3.11/site-packages/beanie/odm/utils/init.py:750: in init_beanie
await Initializer(
.local/lib/python3.11/site-packages/beanie/odm/utils/init.py:128: in __await__
yield from self.init_class(model).__await__()
.local/lib/python3.11/site-packages/beanie/odm/utils/init.py:713: in init_class
await self.init_document(cls)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <beanie.odm.utils.init.Initializer object at 0x7457d1843cd0>
cls = <class 'api.models.User'>
> build_info = await self.database.command({"buildInfo": 1})
E RuntimeError: Task <Task pending name='anyio.from_thread.BlockingPortal._call_func' coro=<BlockingPortal._call_func() running at /home/kernelci/.local/lib/python3.11/site-packages/anyio/from_thread.py:217> cb=[TaskGroup._spawn.<locals>.task_done() at /home/kernelci/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:699]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/lib/python3.11/asyncio/futures.py:387]> attached to a different loop
.local/lib/python3.11/site-packages/beanie/odm/utils/init.py:545: RuntimeError
```
Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
0 commit comments