~/talk

Easy, Breezy, Beautiful... Django Unit Tests with Colleen Dunlap

Talkat DjangoCon US 2025 · on Monday, 2025-09-08· at 10:50· Wolf Point Ballroom· [django, testing]
slides:none on file

Concrete techniques and outcomes, not abstractions: unit tests use Django.test.TestCase and setupTestData to speed runs, Factory Boy and Django model factories to generate realistic fixtures, and Django mock queries or mock.patch to avoid expensive DB work. Assertions include assertNumQueries to catch N+1s and assert_called_with to verify interactions. A grocery subscription case study shows submit/validate/charge/ship paths with payment and shipping APIs mocked, and examples demonstrate reproducible results and measurable speedups.

AI-written summary · about

  1. 0:00Introduction
  2. 2:29What is a unit test
  3. 5:01Behavior vs implementation
  4. 7:32Mocking techniques
  5. 9:20Setup and teardown
  6. 11:49Factories for test data
  7. 14:19Django TestCase benefits
  8. 15:24Efficient test data setup
  9. 16:47Model Factory and signals
  10. 18:36Mocking queries
  11. 20:03Case study walkthrough
  12. 21:53Django assertions
  13. 24:00Serializer testing pitfalls
  14. 25:27Test decorators
  15. 27:11Test command options
  16. 29:02Extending TestCase
  17. 30:51Conclusion and key takeaways
~/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.