mfreeborn / fastapi-sqlalchemy

Adds simple SQLAlchemy support to FastAPI
MIT License
613 stars 37 forks source link

How to use this package with pytest? #3

Closed nf1s closed 4 years ago

nf1s commented 4 years ago

I wonder how to use this package with pytest. to setup a test database and tear down after test is completed

mfreeborn commented 4 years ago

Interesting question. I think one very possible option would be to test using an sqlite in-memory database. With pytest, create a fixture for your app which uses scope=function, then, each new test will have a fresh database.

nf1s commented 4 years ago

Thank you, I will try it out

mfreeborn commented 4 years ago

Good luck, I'll close this for now but happy for it to be re-opened if necessary. It would be great to see your implementation once finished.