vincentporte / fastapi_sqlachemy2_async

FastAPI x sqlAlchemy 2 x postgresql, async mode
MIT License
2 stars 0 forks source link

feat(chore): simplify DB test session management #1

Open vincentporte opened 1 year ago

vincentporte commented 1 year ago

Description

🎸 set db_session as fixture for tests

Type of change

Checklist:

vincentporte commented 1 year ago

test_create_user_async fails.

Failed: [undefined]Fixture "db_session" called directly. Fixtures are not meant to be called directly,
but are created automatically when test functions request them as parameters.

Neither

def test_create_user_async(client, db_session)

nor

@pytest.mark.asyncio
async def test_create_user_async(client, db_session):
    # Ensure the users list is empty before creating a new user
    response = await client.get("/api/users/")
    assert response.status_code == 200

solve the issue