'Easy workaround for having to nest mock.patch context managers'

def create_patch(self, name, return_value=None):

    patcher = patch(name)
    thing = patcher.start()
    if (return_value is not None):
        thing.return_value = return_value
    self.addCleanup(patcher.stop)
    return thing
