Issue #21750: Further fixup to be styled like other mock APIs.

This commit is contained in:
Robert Collins 2015-07-24 03:48:20 +12:00
parent 80e4f30e64
commit ca647ef60a
4 changed files with 68 additions and 37 deletions

View file

@ -1995,9 +1995,11 @@ mock_open
: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. 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.
*read_data* is an empty string by default.
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
<https://pypi.python.org/pypi>`_ can offer a realistic filesystem for testing.
Using :func:`open` as a context manager is a great way to ensure your file handles
are closed properly and is becoming common::