diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-03-25 18:37:46 +0100 |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-03-25 18:37:46 +0100 |
commit | b49cb7b38667e64696eff4833a46036f9f20ac5e (patch) | |
tree | 6a95c27e8e10f41bf7cb1314c9f09a1406f0dec3 | |
parent | 165e9aac1f38c0dbb2d2aee061cd7bda8a486bba (diff) | |
download | mock-b49cb7b38667e64696eff4833a46036f9f20ac5e.tar.gz |
Some test fixes to always clean up patches
-rw-r--r-- | tests/testpatch.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/testpatch.py b/tests/testpatch.py index 5f6a1b1..c9af333 100644 --- a/tests/testpatch.py +++ b/tests/testpatch.py @@ -726,8 +726,8 @@ class PatchTest(unittest2.TestCase): patcher = patch('%s.something' % __name__) self.assertIs(something, original) mock = patcher.start() - self.assertIsNot(mock, original) try: + self.assertIsNot(mock, original) self.assertIs(something, mock) finally: patcher.stop() @@ -746,8 +746,8 @@ class PatchTest(unittest2.TestCase): patcher = patch.object(PTModule, 'something', 'foo') self.assertIs(something, original) replaced = patcher.start() - self.assertEqual(replaced, 'foo') try: + self.assertEqual(replaced, 'foo') self.assertIs(something, replaced) finally: patcher.stop() @@ -761,9 +761,10 @@ class PatchTest(unittest2.TestCase): self.assertEqual(d, original) patcher.start() - self.assertEqual(d, {'spam': 'eggs'}) - - patcher.stop() + try: + self.assertEqual(d, {'spam': 'eggs'}) + finally: + patcher.stop() self.assertEqual(d, original) |