Introduction to Mocking in Python

Prashanth Pai (~prashanthpai)


14

Votes

Description:

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 nicely compliments "Unit testing 101" talk if such a talk has been proposed by someone else.

This talk aims to primarily touch upon the following topics:

  • What is NOT 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 ;)

Prerequisites:

  1. Basic understanding of exception handling, magic methods, decorators etc.
  2. Very basic understanding of unit testing in Python

Knowing unittest and nose modules is a plus but not a pre-requisite per se.

Speaker Info:

Prashanth Pai works as Associate 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:

No comments added so far.

Login to add a new comment.