SQLite is the testing-database superpower
SQLite makes test setup almost free. Three strategies that show up in every well-tested codebase:
- :memory: per test — open
sqlite3.connect(':memory:'), run migrations, run the test, the database disappears at process end. Fastest possible setup. - tempfile per test — like :memory: but file-backed. Useful when the code under test must close + reopen the connection.
- shared template + COPY — build a fixture database once, copy it for each test. Fast when migrations are expensive.
Self-reference: Pippa's tests use the :memory: pattern via a pytest fixture — every store-level test gets a fresh empty database in milliseconds. That's why the backend test suite finishes in ~2 seconds even with 100+ tests.