Secrets of the testing masters
summary
Shows that Django fixtures often turn into 18-line JSON blobs because the default user model has about 12 required fields, and recommends replacing repeated fixtures with Factory Boy factories that declare defaults once, support sequence fields, lazy attributes, subfactories, and build vs create. Demonstrates overriding create to hash passwords, and using mock.patch and mock objects to fake external calls (example: forcing requests.get to return a 401 body "bad login") so tests run fast and reliably.
AI-written summary · about
chapters (6)
- 0:00Introduction to testing
- 2:04The problem with fixtures
- 5:56Factory Boy for test data
- 15:17Challenges of external services
- 18:03Using mock for isolation
- 23:26Questions and conclusion
related talks
32mEasy, Breezy, Beautiful... Django Unit Tests with Colleen Dunlap
35mTurning test writing into a consistently brief and pleasant experience
24mPractical Unit Testing in Django
29m"Testing. Why so serious?"
29mEffective tests and testing effectively
24mGiven this, assert that: fluent testing using fixtures and properties
20mClimbing Out of Fixture Hell, Indirectly
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
