'Test runWithPatches restores the original values even when the function
raises an exception.'

def test_runWithPatchesRestoresOnException(self):

    def _():
        self.assertEqual(self.testObject.foo, 'haha')
        self.assertEqual(self.testObject.bar, 'blahblah')
        raise RuntimeError('Something    went    wrong!')
    self.monkeyPatcher.addPatch(self.testObject, 'foo', 'haha')
    self.monkeyPatcher.addPatch(self.testObject, 'bar', 'blahblah')
    self.assertRaises(RuntimeError, self.monkeyPatcher.runWithPatches, _)
    self.assertEqual(self.testObject.foo, self.originalObject.foo)
    self.assertEqual(self.testObject.bar, self.originalObject.bar)
