O'Reilly logo
live online training icon Live Online training

Test-Driven Development In Python

Master Unit Testing For Python Applications

Aaron Maxwell

The ability to write tests is a programming superpower: a skill that separates average developers from the very best on the planet. Master it, and you can write FAR more complex, powerful software than you ever could before. It can change the arc of your career.

In this hands-on, intermediate Python class, you quickly learn the key concepts of automated testing, and how to apply it to your Python code. These patterns and techniques - which apply to any testing framework - are demonstrated using Python's built-in "unittest" library… letting you transfer what you learn to any xUnit library, in any language. With ongoing live Q&A, and repeated in-class code exercises, this course is the fastest way to add test-driven development to your skill set. Come ready to write code, and quickly learn a lot.

What you'll learn-and how you can apply it

By the end of this live, online course, you’ll understand:

  • The value and benefit of writing tests brings to your code… and your career
  • The key tools and types of automated tests, and where to use them
  • The common code organization and concepts for xUnit Libraries. Not just in Python, but in many other languages

And you’ll be able to:

  • Leverage the most powerful and time-tested patterns for unit tests
  • Write code using a test-driven style of development
  • Effectively organize their test code for even the most complex applications

This training course is for you because...

  • You're a software engineer who cares about robust, reliable, and maintainable code... or you're just sick and tired of wasting your life hunting down stupid bugs
  • You’re a tech lead or engineering manager who wants to improve robustness, code quality, and agility across your entire team
  • You're a data scientist who wants to fearlessly modify numerical code, without worrying about introducing crippling and subtle bugs
  • You're a web developer ready to take on more complex and extensive web applications
  • You're a QA engineer who wants to lead by example, and build more robust tooling
  • You want to improve your Python knowledge to ace an interview or land that dream job


  • Able to run Python programs from the command prompt (necessary for this class)
  • Familiar with writing Python functions, simple classes, and methods
  • Fully able to work with the common Python types and data structures, like lists and dictionaries

Students will be given a link to download materials at the beginning of class.


  • Install Python (3.6+ or later recommended; 2.7 acceptable)

About your instructor

  • Aaron Maxwell is author of the book "Powerful Python: The Most Impactful Patterns, Features, and Development Strategies Modern Python Provides." As a software engineer, he has worked in devops, test automation, and machine learning, and now divides his time between coding, writing, and teaching


The timeframes are only estimates and may vary according to how the class is progressing

  • Intro & logistics
  • Why Writing Tests Is A Superpower
  • The Different Kinds Of Automated Tests
  • Testing Frameworks: The unittest module
  • Unit Tests And Simple Assertions
  • Lab: The Text Body
  • Test Organization
  • Fixtures And Common Test Setup
  • Asserting Exceptions
  • Subtests For Comprehensive Parameterized Tests
  • Lab: More Advanced Testing
  • Mocks For Rapid Indirect Testing
  • Tooling For Test Automation
  • Alternate Frameworks: pytest, doctest, and more

THROUGHOUT: Live Q&A and in-class coding exercises.