Practical Unit Testing in Django
summary
Focuses on concrete unit testing techniques for Django: build a minimal view instance with test instance from RequestFactory, call individual methods directly, and assert behavior rather than the whole stack. Shows mocking and dummy subclasses to isolate class based views, mixins, forms and inlineformset logic, patching super calls and using autospec to assert super called once. Demonstrates deleting mock attributes, mocking ORM chains like filter all count, and unit testing form clean() and save() paths to get high coverage.
AI-written summary · about
chapters (9)
- 0:00Introduction to testing
- 1:34What is unit testing
- 5:08Testing class-based views
- 8:21Testing forms and methods
- 14:23Testing mixins
- 17:00Advanced mocking techniques
- 18:58Testing template tags
- 19:38Summary of unit testing
- 20:41Q&A and conclusion
related talks
32mEasy, Breezy, Beautiful... Django Unit Tests with Colleen Dunlap
29mSecrets of the testing masters
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
35mTurning test writing into a consistently brief and pleasant experience
41mTDD for APIs
22mBDD (Behavior Driven Development) Testing for Django Apps
45mTesting via fake injection in Django
39mUnit Testing for Data Scientists
