From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 9 Jul 2018 00:52:44 +0000 (-0700) Subject: Fix margin in sentinel and mock_open (GH-8188) X-Git-Tag: v3.6.7rc1~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=336c715a82797462fd3beb2a5f309594ce7b7bd0;p=python Fix margin in sentinel and mock_open (GH-8188) (cherry picked from commit f85af035c5cb9a981f5e3164425f27cf73231b5f) Co-authored-by: Andrés Delfino --- diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 9d4d36fe00..6841ef8ecc 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -1825,12 +1825,12 @@ sentinel .. data:: sentinel - The ``sentinel`` object provides a convenient way of providing unique - objects for your tests. + The ``sentinel`` object provides a convenient way of providing unique + objects for your tests. - Attributes are created on demand when you access them by name. Accessing - the same attribute will always return the same object. The objects - returned have a sensible repr so that test failure messages are readable. + Attributes are created on demand when you access them by name. Accessing + the same attribute will always return the same object. The objects + returned have a sensible repr so that test failure messages are readable. The ``sentinel`` attributes don't preserve their identity when they are :mod:`copied ` or :mod:`pickled `. @@ -2069,22 +2069,22 @@ mock_open .. function:: mock_open(mock=None, read_data=None) - A helper function to create a mock to replace the use of :func:`open`. It works - for :func:`open` called directly or used as a context manager. - - The *mock* argument is the mock object to configure. If ``None`` (the - default) then a :class:`MagicMock` will be created for you, with the API limited - to methods or attributes available on standard file handles. - - *read_data* is a string for the :meth:`~io.IOBase.read`, - :meth:`~io.IOBase.readline`, and :meth:`~io.IOBase.readlines` methods - of the file handle to return. Calls to those methods will take data from - *read_data* until it is depleted. The mock of these methods is pretty - simplistic: every time the *mock* is called, the *read_data* is rewound to - the start. If you need more control over the data that you are feeding to - the tested code you will need to customize this mock for yourself. When that - is insufficient, one of the in-memory filesystem packages on `PyPI - `_ can offer a realistic filesystem for testing. + A helper function to create a mock to replace the use of :func:`open`. It works + for :func:`open` called directly or used as a context manager. + + The *mock* argument is the mock object to configure. If ``None`` (the + default) then a :class:`MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + *read_data* is a string for the :meth:`~io.IOBase.read`, + :meth:`~io.IOBase.readline`, and :meth:`~io.IOBase.readlines` methods + of the file handle to return. Calls to those methods will take data from + *read_data* until it is depleted. The mock of these methods is pretty + simplistic: every time the *mock* is called, the *read_data* is rewound to + the start. If you need more control over the data that you are feeding to + the tested code you will need to customize this mock for yourself. When that + is insufficient, one of the in-memory filesystem packages on `PyPI + `_ can offer a realistic filesystem for testing. .. versionchanged:: 3.4 Added :meth:`~io.IOBase.readline` and :meth:`~io.IOBase.readlines` support.