In-memory ORM’s don’t really work since the Django ORM is really an SQL generator. It would also prevent you from using more advanced features.
You can speed up PostgreSQL by mounting it on an in-memory filesystem. In docker-compose this is as easy as:
...
services:
postgres:
image: postgis/postgis:12-3.0
ports:
- 5432:5432
volumes:
- type=tmpfs,destination=/var/lib/postgresql/data
The other thing you can do is reduce the amount of database usage in your tests. A key way to achieve this is to use setUpTestData
, alongside making sure you use TestCase
instead of TransactionTestCase
as much as possible.
There’s a lot to cover here… so much I wrote a book… 