From 6cbb8cb1f74db591c65ec93fa29bb1c018c58bfe Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 10 Nov 2025 01:08:30 +0100 Subject: [PATCH] [3.14] gh-62480: De-personalize "Partial mocking" section in `unittest.mock` examples (GH-141321) (#141326) gh-62480: De-personalize "Partial mocking" section in `unittest.mock` examples (GH-141321) * Refine some wording in unittest partial mock doc Some of the descriptions were addressed in first person, but have now been changed to address the user reading the documentation instead. (cherry picked from commit b618731781c31d4b5b75d199dfc14993ffd66e37) Co-authored-by: KarnbirKhera <166065758+KarnbirKhera@users.noreply.github.com> Co-authored-by: C.A.M. Gerlach --- Doc/library/unittest.mock-examples.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst index e2b0322dae04..6af4298d44f5 100644 --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -600,13 +600,13 @@ this list of calls for us:: Partial mocking ~~~~~~~~~~~~~~~ -In some tests I wanted to mock out a call to :meth:`datetime.date.today` -to return a known date, but I didn't want to prevent the code under test from -creating new date objects. Unfortunately :class:`datetime.date` is written in C, and -so I couldn't just monkey-patch out the static :meth:`datetime.date.today` method. +For some tests, you may want to mock out a call to :meth:`datetime.date.today` +to return a known date, but don't want to prevent the code under test from +creating new date objects. Unfortunately :class:`datetime.date` is written in C, +so you cannot just monkey-patch out the static :meth:`datetime.date.today` method. -I found a simple way of doing this that involved effectively wrapping the date -class with a mock, but passing through calls to the constructor to the real +Instead, you can effectively wrap the date +class with a mock, while passing through calls to the constructor to the real class (and returning real instances). The :func:`patch decorator ` is used here to -- 2.47.3