Hi guys ! Putting this to reference this issue, not solution yet.
Running this test return a warning and not push data into DB :
pytestmark = pytest.mark.anyio
#remove trio from tests
@pytest.fixture(scope="session")
def anyio_backend() -> str:
return "asyncio"
@pytest.fixture(scope="function")
async def test_client() -> AsyncIterator[AsyncTestClient[Litestar]]:
async with AsyncTestClient(app=test_app) as client:
yield client
class TestAccess:
jwt_token:str = None
async def test_create_access(self, test_client: AsyncTestClient[Litestar]) -> None:
data = {
"email": "[email protected]",
"password": "Pouet123!"
}
response = await test_client.post(urls.ACCESS_REGISTER, json=data)
assert response.status_code == status_codes.HTTP_201_CREATED
async def test_login_access(self, test_client: AsyncTestClient[Litestar]) -> None:
data = {
"email": "[email protected]",
"password": "Pouet123!"
}
response = await test_client.post(urls.ACCESS_LOGIN, data=data) #need to login with formdata and not json
self.jwt_token = response.headers['authorization']
assert response.status_code == status_codes.HTTP_201_CREATED
The error : sys:1: SAWarning: The garbage collector is trying to clean up non-checked-in connection <AdaptedConnection <Connection(Thread-3, stopped daemon 1216)>>, which will be dropped, as it cannot be safely terminated. Please ensure that SQLAlchemy pooled connections are returned to the pool explicitly, either by calling close() or by using appropriate context managers to manage their lifecycle.