Testing Django
summary
Recommends avoid fixtures and use Factory Boy to build or create model instances with sequences and subfactories, showing a PostFactory that auto-creates an author; prefers use WebTest not Selenium for faster functional tests (no JS/Ajax, not a headless browser) and webtest-django helpers for auth and headers like X-Requested-With or JWT. Advocates small, dumb tests, keep tests simple and repeat rather than loops or logic, use eager Celery for tests, and notes ~300 tests run ~30s locally vs ~5min on Postgres.
AI-written summary · about
chapters (18)
- 0:00Introduction to Django testing
- 1:05Avoiding fixtures in tests
- 2:33Using Factory Boy for data
- 4:47WebTest for functional tests
- 8:45Testing API endpoints
- 13:27Keeping tests simple
- 16:00Avoiding mocks in tests
- 17:10No logic in tests
- 18:37One test per scenario
- 20:00Testing non-Django frameworks
- 21:06Avoid testing views
- 22:50Test execution speed
- 24:14Testing as black box
- 25:37Minimize test logic
- 26:18Async tasks in tests
- 27:02Pragmatic testing approach
- 29:32TDD as methodology
- 30:36Team testing agreement
