Unit testing 101

Prashanth Pai (~prashanthpai)




This talk aims to introduce attendees to unit testing in Python using the built-in unittest module and also emphasize on how crucial unit testing is. mock is a Python testing module that allows you to replace parts (methods, classes etc) of your application with mock objects and make assertions about how they have been used.

This talk aims to primarily touch upon the following topics:

  • What is NOT a unit test ?
  • Conventions and anatomy of a unit test
  • Why do you need mocking ?
  • Monkey Patching: Where, why and what to patch
  • Mocking network calls and I/O

Also illustrate examples of real code that use the above techniques. Among the things that I certainly do not wish to talk about is compare various mocking libraries. For example mock vs mox ;)


Basic understanding of Python.

Speaker Info:

Prashanth Pai works as Software Engineer at Red Hat. He is primarily associated with and contributes to the following open source projects:

OpenStack Swift: A highly available, distributed, eventually consistent object store.
GlusterFS: A highly scalable distributed filesystem.

Speaker Links:

Find me on GitHub
Previous talks

Section: Testing
Type: Talks
Target Audience: Beginner
Last Updated: