bpo-32299: Return patched dict when using patch.dict as a context manager (GH-11062)

This commit is contained in:
Mario Corchero 2019-05-28 13:53:31 +01:00 committed by Cheryl Sabella
parent eb65e2443a
commit 04530812e9
4 changed files with 20 additions and 1 deletions

View file

@ -619,6 +619,13 @@ class PatchTest(unittest.TestCase):
self.assertEqual(foo.values, original)
def test_patch_dict_as_context_manager(self):
foo = {'a': 'b'}
with patch.dict(foo, a='c') as patched:
self.assertEqual(patched, {'a': 'c'})
self.assertEqual(foo, {'a': 'b'})
def test_name_preserved(self):
foo = {}