Testing FastAPI with Tortoise ORM #1120
Unanswered
michalmalara
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Can you show the code inside th initializer function ? |
Beta Was this translation helpful? Give feedback.
0 replies
-
The initializer function is from tortoise orm: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with running tests. I use FastAPI with Tortoise ORM, and normally I use sqlite file to store my data in a file (for now, I'll use probably postges on production) and everything is OK. The problem shows up when I'm trying to run tests. I want to override database URL to be in-memory database, but it doesn't work and uses this "production" database instead. When I run test after deleting the db file, they pass, but next time it doesn't, because user I create during test already exists. How can I force my configuration to override db url?
main.py
conftest.py
test_users.py
I tried setting URL in environment variables and change it in pytest fixture, but it didn't help.
I don't want to remove db file after testing, because it could remove my data I use to develop app and my manual testing.
Beta Was this translation helpful? Give feedback.
All reactions