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
Hi @foarsitter! Overriding the dependency shouldn't be necessary since we patch the engine factory used to generate the sessions. Can you try updating your test so that the session fixture is before the app fixture in the test function signature, so that it's loaded before the app by pytest?
When using the
fastapi.testclient.TestClient
with pytest, the app doesn't use the session fixture resulting in writes to the database.To solve this problem, pytest needs to tell the app to use the same session as used for testing. This can be done by using
dependency_overrides
.At least, this is how I solved the problem. Is there a beter approach or should I send a PR to document this?
The text was updated successfully, but these errors were encountered: