bpo-40126: Fix reverting multiple patches in unittest.mock. (GH-19351)

Patcher's __exit__() is now never called if its __enter__() is failed.
Returning true from __exit__() silences now the exception.
This commit is contained in:
Serhiy Storchaka 2020-04-11 10:59:24 +03:00 committed by GitHub
parent cd8295ff75
commit 4b222c9491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 48 deletions

View file

@ -774,7 +774,7 @@ class PatchTest(unittest.TestCase):
d = {'foo': 'bar'}
original = d.copy()
patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
self.assertEqual(patcher.stop(), False)
self.assertFalse(patcher.stop())
self.assertEqual(d, original)