diff options
author | Dominic H <dom@dominic.sk> | 2024-07-15 07:14:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 07:14:17 (GMT) |
commit | 8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be (patch) | |
tree | 408086e9a2ec8274f33c1b2f59723bebb81dcd8f | |
parent | 48042c52a6b59089e7d7dda3c8fed79d646b6f8d (diff) | |
download | cpython-8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be.zip cpython-8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be.tar.gz cpython-8303d32ff55945c5b38eeeaf1b1811dbcf8aa9be.tar.bz2 |
gh-117765: Improve documentation for `mocker.patch.dict` (#121755)
-rw-r--r-- | Doc/library/unittest.mock.rst | 3 | ||||
-rw-r--r-- | Lib/unittest/mock.py | 3 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Documentation/2024-07-14-12-25-53.gh-issue-117765.YFMOUv.rst | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index d8ba24c..01206e0 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 d50535d..2bbbcf4 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 0000000..a727c1a --- /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` |