Skip to content

Commit 5141b1e

Browse files
authored
gh-101100: Fix sphinx warnings in unittest.mock-examples.rst (#108810)
1 parent dd05c20 commit 5141b1e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Doc/library/unittest.mock-examples.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,14 @@ Partial mocking
579579
In some tests I wanted to mock out a call to :meth:`datetime.date.today`
580580
to return a known date, but I didn't want to prevent the code under test from
581581
creating new date objects. Unfortunately :class:`datetime.date` is written in C, and
582-
so I couldn't just monkey-patch out the static :meth:`date.today` method.
582+
so I couldn't just monkey-patch out the static :meth:`datetime.date.today` method.
583583

584584
I found a simple way of doing this that involved effectively wrapping the date
585585
class with a mock, but passing through calls to the constructor to the real
586586
class (and returning real instances).
587587

588588
The :func:`patch decorator <patch>` is used here to
589-
mock out the ``date`` class in the module under test. The :attr:`side_effect`
589+
mock out the ``date`` class in the module under test. The :attr:`~Mock.side_effect`
590590
attribute on the mock date class is then set to a lambda function that returns
591591
a real date. When the mock date class is called a real date will be
592592
constructed and returned by ``side_effect``. ::
@@ -766,8 +766,8 @@ mock has a nice API for making assertions about how your mock objects are used.
766766
>>> mock.foo_bar.assert_called_with('baz', spam='eggs')
767767

768768
If your mock is only being called once you can use the
769-
:meth:`assert_called_once_with` method that also asserts that the
770-
:attr:`call_count` is one.
769+
:meth:`~Mock.assert_called_once_with` method that also asserts that the
770+
:attr:`~Mock.call_count` is one.
771771

772772
>>> mock.foo_bar.assert_called_once_with('baz', spam='eggs')
773773
>>> mock.foo_bar()
@@ -835,7 +835,7 @@ One possibility would be for mock to copy the arguments you pass in. This
835835
could then cause problems if you do assertions that rely on object identity
836836
for equality.
837837

838-
Here's one solution that uses the :attr:`side_effect`
838+
Here's one solution that uses the :attr:`~Mock.side_effect`
839839
functionality. If you provide a ``side_effect`` function for a mock then
840840
``side_effect`` will be called with the same args as the mock. This gives us an
841841
opportunity to copy the arguments and store them for later assertions. In this
@@ -971,7 +971,8 @@ We can do this with :class:`MagicMock`, which will behave like a dictionary,
971971
and using :data:`~Mock.side_effect` to delegate dictionary access to a real
972972
underlying dictionary that is under our control.
973973

974-
When the :meth:`__getitem__` and :meth:`__setitem__` methods of our ``MagicMock`` are called
974+
When the :meth:`~object.__getitem__` and :meth:`~object.__setitem__` methods
975+
of our ``MagicMock`` are called
975976
(normal dictionary access) then ``side_effect`` is called with the key (and in
976977
the case of ``__setitem__`` the value too). We can also control what is returned.
977978

Doc/library/uuid.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ which relays any information about the UUID's safety, using this enumeration:
101101
- Meaning
102102

103103
* - .. attribute:: UUID.time_low
104-
- The next 32 bits of the UUID.
104+
- The first 32 bits of the UUID.
105105

106106
* - .. attribute:: UUID.time_mid
107107
- The next 16 bits of the UUID.

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ Doc/library/tkinter.ttk.rst
131131
Doc/library/traceback.rst
132132
Doc/library/tty.rst
133133
Doc/library/turtle.rst
134-
Doc/library/unittest.mock-examples.rst
135134
Doc/library/unittest.mock.rst
136135
Doc/library/unittest.rst
137136
Doc/library/urllib.parse.rst

0 commit comments

Comments
 (0)