Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
"alias": "video/392/pycon-2011--testing-with-mock",
"category": "PyCon US 2011",
"copyright_text": "Creative Commons Attribution-NonCommercial-ShareAlike 3.0",
"description": "Testing with mock\n\nPresented by Michael Foord\n\nmock is a Python testing library. It has the goal of making mocking in\ntests brain dead simple! mock provides the Mock class and the patch\ndecorator for safely patching out the objects you are mocking in your\ntests. This talk will cover standard mocking patterns. We'll also look\nat some of the newer features in the latest release, including support\nfor mocking magic methods.\n\nAbstract\n\nmock provides a core Mock class that removes the need to create a host\nof trivial stubs throughout your test suite. After performing an action,\nyou can make assertions about which methods / attributes were used and\narguments they were called with. You can also specify return values and\nset specific attributes in the normal way.\n\n-\n-\n\nThe mock module also provides a patch() decorator that handles safely\npatching out the things you are mocking during your test.\n\nWe'll cover standard mocking patterns, and how mock makes them easy.\nWe'll also be looking at some of the newer features in the latest\nrelease, including the magic method support that can be used (for\nexample) for mocking out objects used as context managers.\n\nmock is designed for \"unit test style\" testing, but is used with Python\ntesting libraries like nose and py.test.\n\nThere will be some emphasis on how *not* to use mocking in testing, and\nwhy 'over mocking' is bad (and makes for brittle tests).\n",
"duration": null,
"id": 392,
"language": "eng",
"quality_notes": "",
"recorded": "2011-03-11",
"related_urls": [
"slug": "pycon-2011--testing-with-mock",
"speakers": [
"Michael Foord"
"summary": "",
"tags": [
"thumbnail_url": "",
"title": "Testing with mock",
"videos": [
"type": "",
"url": ""