~/talk

Follow the Postgres brick road: a journey of testing against a real database server

Talkat PyCon AU 2024 · 2024-11-22..11-26· [databases, testing]
slides:none on file

Swapping SQLite tests for a real PostgreSQL server (run via Docker Compose) fixes type and dialect mismatches and moves test setup from fragile mocks to running migrations with Alembic and SQLAlchemy. The pipeline creates a template DB and caches it cache keyed by migration hash, cutting migration setup from ~3 seconds to ~0.5s (and individual tests to ~10ms). Tests use a session-scoped DB plus per-test transactions with rollback and an assertion that detects stray commits transactions + rollback with commit-detection, enabling parallel isolated pytest runs.

AI-written summary · about

  1. 0:00Welcome
  2. 0:49Speaker and journey
  3. 2:14Effective database testing
  4. 3:37SQLite testing pitfalls
  5. 6:45Real Postgres for tests
  6. 7:49Test DB with migrations
  7. 10:16Caching schemas
  8. 14:12Test independence with transactions
  9. 19:50Avoid accidental commits
  10. 23:19Parallel tests with unique DBs
  11. 25:06Models vs migrations
  12. 27:54Schema consistency checks
  13. 29:41Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.