https://github.com/python/cpython/commit/8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be
commit: 8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be
branch: main
author: Dominic H <[email protected]>
committer: cjw296 <[email protected]>
date: 2024-07-15T07:14:17Z
summary:
gh-117765: Improve documentation for `mocker.patch.dict` (#121755)
files:
A Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst
M Doc/library/unittest.mock.rst
M Lib/unittest/mock.py
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index d8ba24c3146cf2..01206e05f4ba01 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -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
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index d50535dffeb5d1..2bbbcf40e21543 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -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
index 00000000000000..a727c1aa9a0571
--- /dev/null
+++
b/Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst
@@ -0,0 +1 @@
+Improved documentation for :func:`unittest.mock.patch.dict`
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]