]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117765: Improve documentation for `mocker.patch.dict` (#121755)
authorDominic H <dom@dominic.sk>
Mon, 15 Jul 2024 07:14:17 +0000 (09:14 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jul 2024 07:14:17 +0000 (07:14 +0000)
Doc/library/unittest.mock.rst
Lib/unittest/mock.py
Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst [new file with mode: 0644]

index d8ba24c3146cf2b48318f4ef253cd4cddd6e6e52..01206e05f4ba01168dd0b0a7bcc05744d4fe9726 100644 (file)
@@ -1624,7 +1624,8 @@ patch.dict
 .. function:: patch.dict(in_dict, values=(), clear=False, **kwargs)
 
     Patch a dictionary, or dictionary like object, and restore the dictionary
-    to its original state after the test.
+    to its original state after the test, where the restored dictionary is a
+    copy of the dictionary as it was before the test.
 
     *in_dict* can be a dictionary or a mapping like container. If it is a
     mapping then it must at least support getting, setting and deleting items
index d50535dffeb5d1835000f0ef0e19eb96e81352be..2bbbcf40e21543e6c65d8419046329d81b04587b 100644 (file)
@@ -1829,7 +1829,8 @@ def patch(
 class _patch_dict(object):
     """
     Patch a dictionary, or dictionary like object, and restore the dictionary
-    to its original state after the test.
+    to its original state after the test, where the restored dictionary is
+    a copy of the dictionary as it was before the test.
 
     `in_dict` can be a dictionary or a mapping like container. If it is a
     mapping then it must at least support getting, setting and deleting items
diff --git a/Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst b/Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst
new file mode 100644 (file)
index 0000000..a727c1a
--- /dev/null
@@ -0,0 +1 @@
+Improved documentation for :func:`unittest.mock.patch.dict`