Skip to content

Commit b618731

Browse files
gh-62480: De-personalize "Partial mocking" section in unittest.mock examples (#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. Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
1 parent ec85d3c commit b618731

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/unittest.mock-examples.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,13 @@ this list of calls for us::
600600
Partial mocking
601601
~~~~~~~~~~~~~~~
602602

603-
In some tests I wanted to mock out a call to :meth:`datetime.date.today`
604-
to return a known date, but I didn't want to prevent the code under test from
605-
creating new date objects. Unfortunately :class:`datetime.date` is written in C, and
606-
so I couldn't just monkey-patch out the static :meth:`datetime.date.today` method.
603+
For some tests, you may want to mock out a call to :meth:`datetime.date.today`
604+
to return a known date, but don't want to prevent the code under test from
605+
creating new date objects. Unfortunately :class:`datetime.date` is written in C,
606+
so you cannot just monkey-patch out the static :meth:`datetime.date.today` method.
607607

608-
I found a simple way of doing this that involved effectively wrapping the date
609-
class with a mock, but passing through calls to the constructor to the real
608+
Instead, you can effectively wrap the date
609+
class with a mock, while passing through calls to the constructor to the real
610610
class (and returning real instances).
611611

612612
The :func:`patch decorator <patch>` is used here to

0 commit comments

Comments
 (0)