Test-Driven Development with Python, Flask, and Docker

Learn how to build, test, and deploy a microservice powered by Python, Flask, and Docker!

"Code without tests is broken by design." - Jacob Kaplan-Moss

Learning Objectives

By the end of this course, you will be able to:

  1. Develop a RESTful API with Python and Flask
  2. Practice Test-Driven Development
  3. Test a Flask app with Pytest
  4. Containerize Flask and Postgres inside a Docker container
  5. Run unit and integration tests with code coverage inside a Docker container
  6. Check your code for any code quality issues via a linter
  7. Configure GitLab CI for continuous integration and deployment
  8. Speed up a Docker-based CI build with Docker Cache
  9. Deploy Flask, Gunicorn, and Postgres to Heroku with Docker
  10. Configure Flask-Admin with SQLAlchemy models

Tools and Technologies

  1. Python
  2. Flask
  3. Docker
  4. Postgres
  5. Pytest
  6. Flask-RESTful
  7. Flask-SQLAlchemy
  8. Gunicorn
  9. Coverage.py
  10. flake8
  11. Black
  12. isort
  13. HTTPie
  14. Flask-Admin
  15. GitLab
  16. Heroku

flask tdd logo


This is not a beginner course. It's designed for the advanced-beginner -- someone with at least six months of web development experience. Before beginning, you should have some familiarity with the following topics. Refer to these resources for more info:

Topic Resource
Docker Get started with Docker
Docker Compose Get started with Docker Compose
Flask Flaskr TDD



  • Current version: 1.0.0
  • Last updated: September 30th, 2019
  • AuthorMichael Herman

Table of Contents

  • Introduction
  • Changelog
  • Getting Started
  • Docker Config
  • Postgres Setup
  • Pytest Setup
  • Flask Blueprints
  • RESTful Routes
  • Deployment
  • Code Coverage and Quality
  • Continuous Integration
  • Continuous Delivery
  • Remaining Routes
  • Flask Admin
  • Workflow
  • Structure
  • Next Steps

Join our mailing list to be notified about course updates and new tutorials.