I copied it from the patch example: http://www.voidspace.org.uk/python/mock/patch.html#patch-dict