Advanced Unit Testing in Python

Published on 04/12/2016


You learned about unit testing or you heard about TDD. You're convinced that they are useful and you want to start with it in your own projects. The introductory examples are simple: you call a function with certain arguments and you assert that an expected result comes back. But you don't have just a bunch of simple pure functions in your own projects and you don't know how to test it.

What you need are the right tools:

  • Stubs and mocks - What are they? When do I want to use them? When do you not want to use them?
  • Patterns for creating your test objects
  • Patterns for organizing your tests