~/talk

Efficient FastAPI testing with pytest, dependency injection and snapshots

Talkat PyCon Italia 2025 · 2025-05-28..05-31· [testing, developer-experience]
slides:none on file

Claim: using FastAPI dependency injection, pytest factory fixtures, and snapshot testing cuts maintenance and catches unintended API changes. Demonstration builds a simple to‑do API with both SQLite and an in‑memory repository, adds a required priority field and shows how hundreds of tests would break but require only a single factory change to fix. Uses a fixed UID provider so snapshots remain stable, runs faster when swapping in-memory repo, and the approach works in the demo.

AI-written summary · about

  1. 0:00Introduction
  2. 1:11Purpose of automated testing
  3. 7:35Common testing problems
  4. 16:19Factory fixtures for tests
  5. 20:21Using snapshots in testing
  6. 21:45Dependency injection in FastAPI
  7. 27:11Implementing efficient tests
  8. 33:12Comparing test approaches
  9. 35:57Q&A
~/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.