Testing Django Applications with pytest
summary
Shows how to run Django tests using pytest and the pytest-django plugin, using helpers like the test client and factory to assert a homepage returns HTTP 200 and a fixture that creates a Question object then checks Question.objects.count. Explains pytest markers (django_db, skip, xfail) and parametrize for repeated cases, and covers speeding tests with pytest-xdist (e.g. -n4) and reuse_db to avoid recreating test databases.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:08Testing Django apps
- 3:38pytest discovery in Django
- 5:13Exception testing
- 6:17Markers for control
- 8:04Custom test discovery
- 9:26Fixtures for setup
- 12:14Running tests in parallel
- 14:03Database reuse
- 16:09Marking DB access
- 19:17Creating fixtures
- 22:09Django pytest helpers
- 25:22Advanced pytest features
- 29:15Learning resources
- 35:43Q&A
