I create an aioredis connection pool in startup_event like this
r = await create_redis_pool(address=(REDIS_HOST, REDIS_PORT), encoding='utf-8')
and (according to aioredis) closing the connection in shutdown_event like this:
r.close() await r.wait_closed()
Launching the project on local machine all works fine, the problem is when you create tests for this.
with TestClient(app).websocket_connect('/ws/') as ws: ws.send_text('hello')
The view tries to access aioredis, but it throughs an error:
aioredis.errors.PoolClosedError: Pool is closed
same setup works perfectly fine with tests for http endpoints:
with TestClient(app) as client: client.post("/not_ws/", json=data)
Can someone please help me?