Setup pytest-django with pytest-postgresql

At work we have a pretty standard stack for the backend. A Django monolith app with relationnal DB, PostgreSQL. When revamping our test infrastructure, I traded reliablity for speed, using sqlite with spatialite. Setup of spatialite on macOS can be quite cumbersome to make it work with python (I’m skipping this part here). The setup turn out to be not so simple because I wanted: setup of 3 DB. fast setup/teardown. It turns out pytest-postgresql, which will starts a postgresql cluster on your machine, is way faster than using testcontainer. ...

May 22, 2025 · 4 min · 713 words · Rémi Desgrange