Skip to content

Commit 79c6b35

Browse files
Fix margin in sentinel and mock_open (GH-8188)
(cherry picked from commit f85af03) Co-authored-by: Andrés Delfino <[email protected]>
1 parent 0b63759 commit 79c6b35

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

Doc/library/unittest.mock.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,12 +1825,12 @@ sentinel
18251825

18261826
.. data:: sentinel
18271827

1828-
The ``sentinel`` object provides a convenient way of providing unique
1829-
objects for your tests.
1828+
The ``sentinel`` object provides a convenient way of providing unique
1829+
objects for your tests.
18301830

1831-
Attributes are created on demand when you access them by name. Accessing
1832-
the same attribute will always return the same object. The objects
1833-
returned have a sensible repr so that test failure messages are readable.
1831+
Attributes are created on demand when you access them by name. Accessing
1832+
the same attribute will always return the same object. The objects
1833+
returned have a sensible repr so that test failure messages are readable.
18341834

18351835
.. versionchanged:: 3.7
18361836
The ``sentinel`` attributes now preserve their identity when they are
@@ -2070,22 +2070,22 @@ mock_open
20702070

20712071
.. function:: mock_open(mock=None, read_data=None)
20722072

2073-
A helper function to create a mock to replace the use of :func:`open`. It works
2074-
for :func:`open` called directly or used as a context manager.
2075-
2076-
The *mock* argument is the mock object to configure. If ``None`` (the
2077-
default) then a :class:`MagicMock` will be created for you, with the API limited
2078-
to methods or attributes available on standard file handles.
2079-
2080-
*read_data* is a string for the :meth:`~io.IOBase.read`,
2081-
:meth:`~io.IOBase.readline`, and :meth:`~io.IOBase.readlines` methods
2082-
of the file handle to return. Calls to those methods will take data from
2083-
*read_data* until it is depleted. The mock of these methods is pretty
2084-
simplistic: every time the *mock* is called, the *read_data* is rewound to
2085-
the start. If you need more control over the data that you are feeding to
2086-
the tested code you will need to customize this mock for yourself. When that
2087-
is insufficient, one of the in-memory filesystem packages on `PyPI
2088-
<https://pypi.org>`_ can offer a realistic filesystem for testing.
2073+
A helper function to create a mock to replace the use of :func:`open`. It works
2074+
for :func:`open` called directly or used as a context manager.
2075+
2076+
The *mock* argument is the mock object to configure. If ``None`` (the
2077+
default) then a :class:`MagicMock` will be created for you, with the API limited
2078+
to methods or attributes available on standard file handles.
2079+
2080+
*read_data* is a string for the :meth:`~io.IOBase.read`,
2081+
:meth:`~io.IOBase.readline`, and :meth:`~io.IOBase.readlines` methods
2082+
of the file handle to return. Calls to those methods will take data from
2083+
*read_data* until it is depleted. The mock of these methods is pretty
2084+
simplistic: every time the *mock* is called, the *read_data* is rewound to
2085+
the start. If you need more control over the data that you are feeding to
2086+
the tested code you will need to customize this mock for yourself. When that
2087+
is insufficient, one of the in-memory filesystem packages on `PyPI
2088+
<https://pypi.org>`_ can offer a realistic filesystem for testing.
20892089

20902090
.. versionchanged:: 3.4
20912091
Added :meth:`~io.IOBase.readline` and :meth:`~io.IOBase.readlines` support.

0 commit comments

Comments
 (0)