summaryrefslogtreecommitdiff
path: root/Lib/unittest/test/testmock/testpatch.py
diff options
context:
space:
mode:
authorMario Corchero <mcorcherojim@bloomberg.net>2019-05-28 13:53:31 +0100
committerCheryl Sabella <cheryl.sabella@gmail.com>2019-05-28 08:53:30 -0400
commit04530812e90e45a37ed84e83505d63db7edc1262 (patch)
treec26e4f6492e37209667b61943cb5a156c2f57aeb /Lib/unittest/test/testmock/testpatch.py
parenteb65e2443ac21739baf6d373abc7b4638b9d6927 (diff)
downloadcpython-git-04530812e90e45a37ed84e83505d63db7edc1262.tar.gz
bpo-32299: Return patched dict when using patch.dict as a context manager (GH-11062)
Diffstat (limited to 'Lib/unittest/test/testmock/testpatch.py')
-rw-r--r--Lib/unittest/test/testmock/testpatch.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index 3295c5b242..27914a9d71 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -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 = {}