This is a tutorial app build for my blog post
docker-compose run app pytest
docker-compose run app alembic revision --autogenerate
docker-compose run app alembic upgrate head
This PR alters conftest.py to do the database setup once at the start of the test run, then execute each test case inside a transaction that is rolled back automatically at the end of each test. This speeds things up a fair bit.
Also, a dedicated test database is created and destroyed for each test run, which avoids clearing data in the local db
Finally - database tables are created by explicitly running the alembic migrations rather than via the metadata. This ensures that migrations are also tested.
Updated a few dependencies along the way
🐍 Senior Software Engineer @ mizar.com Passionate pythonista, focused on new technologies and problem-solving.GitHub Repository
python sqlalchemy asyncio fastapi