Testing Best Practices (Tutorial)
summary
Hands-on Flask tutorial that refactors a small Hacker News demo into testable library functions, shows how to replace live HTTP calls with mock.patch or the responses library, and exercises CLI and web flows so the same code formats HTML for browsers and plain text for commands. Covers testing databases (schema recreation per run), emails via Flask-Mail outbox or a fake SMTP server, using Docker/docker-compose for services, pytest fixtures, and CI tricks that cut a 1‑hour run to ~10–15 minutes.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker background
- 1:50Why automated testing is hard
- 5:21Tests as expense asset or liability
- 13:44Making tests easy to set up
- 24:47Starting the interactive tutorial
- 32:24Test principles and CLI exceptions
- 43:04Web test integration and refactoring
- 1:00:57Reviewing CLI and library code
- 1:19:05Mocking external services and state management
- 1:27:19Email testing with mocking methods
- 1:36:24Database state and generators
- 1:39:43Final advice and conclusion
