Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 336c715

Browse filesBrowse files
Fix margin in sentinel and mock_open (GH-8188)
(cherry picked from commit f85af03) Co-authored-by: Andrés Delfino <adelfino@gmail.com>
1 parent 4041565 commit 336c715
Copy full SHA for 336c715

File tree

Expand file treeCollapse file tree

1 file changed

+21
-21
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-21
lines changed

‎Doc/library/unittest.mock.rst

Copy file name to clipboardExpand all lines: Doc/library/unittest.mock.rst
+21-21Lines 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
The ``sentinel`` attributes don't preserve their identity when they are
18361836
:mod:`copied <copy>` or :mod:`pickled <pickle>`.
@@ -2069,22 +2069,22 @@ mock_open
20692069

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

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.