Skip to content

Commit d74e296

Browse files
committed
[3.12] pythongh-101100: Fix sphinx warnings in unittest.mock-examples.rst (pythonGH-108810).
(cherry picked from commit 5141b1e) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent 4dc07d2 commit d74e296

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
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: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,34 @@ which relays any information about the UUID's safety, using this enumeration:
9595
A tuple of the six integer fields of the UUID, which are also available as six
9696
individual attributes and two derived attributes:
9797

98-
+------------------------------+-------------------------------+
99-
| Field | Meaning |
100-
+==============================+===============================+
101-
| :attr:`time_low` | the first 32 bits of the UUID |
102-
+------------------------------+-------------------------------+
103-
| :attr:`time_mid` | the next 16 bits of the UUID |
104-
+------------------------------+-------------------------------+
105-
| :attr:`time_hi_version` | the next 16 bits of the UUID |
106-
+------------------------------+-------------------------------+
107-
| :attr:`clock_seq_hi_variant` | the next 8 bits of the UUID |
108-
+------------------------------+-------------------------------+
109-
| :attr:`clock_seq_low` | the next 8 bits of the UUID |
110-
+------------------------------+-------------------------------+
111-
| :attr:`node` | the last 48 bits of the UUID |
112-
+------------------------------+-------------------------------+
113-
| :attr:`time` | the 60-bit timestamp |
114-
+------------------------------+-------------------------------+
115-
| :attr:`clock_seq` | the 14-bit sequence number |
116-
+------------------------------+-------------------------------+
98+
.. list-table::
99+
100+
* - Field
101+
- Meaning
102+
103+
* - .. attribute:: UUID.time_low
104+
- The first 32 bits of the UUID.
105+
106+
* - .. attribute:: UUID.time_mid
107+
- The next 16 bits of the UUID.
108+
109+
* - .. attribute:: UUID.time_hi_version
110+
- The next 16 bits of the UUID.
111+
112+
* - .. attribute:: UUID.clock_seq_hi_variant
113+
- The next 8 bits of the UUID.
114+
115+
* - .. attribute:: UUID.clock_seq_low
116+
- The next 8 bits of the UUID.
117+
118+
* - .. attribute:: UUID.node
119+
- The last 48 bits of the UUID.
120+
121+
* - .. attribute:: UUID.time
122+
- The 60-bit timestamp.
123+
124+
* - .. attribute:: UUID.clock_seq
125+
- The 14-bit sequence number.
117126

118127

119128
.. attribute:: UUID.hex

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ Doc/library/tkinter.ttk.rst
145145
Doc/library/traceback.rst
146146
Doc/library/tty.rst
147147
Doc/library/turtle.rst
148-
Doc/library/unittest.mock-examples.rst
149148
Doc/library/unittest.mock.rst
150149
Doc/library/unittest.rst
151150
Doc/library/urllib.parse.rst

0 commit comments

Comments
 (0)